0

I have been using git to make some changes to my project. I added the files I changed and then committed those changes. When I tried to push the changes I got the following. Could someone help explain what I am doing wrong? Any help will be appreciated

C:\Users\Ace\Desktop\GitHub\ProjectZero [master]> git push

Warning: Permanently added 'IP ADDRESS' (RSA) to the list of known hosts.    
Counting objects: 11, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (5/5), done.
Writing objects: 100% (6/6), 599 bytes | 0 bytes/s, done.
Total 6 (delta 4), reused 0 (delta 0)
remote: error: refusing to update checked out branch: refs/heads/master
remote: error: By default, updating the current branch in a non-bare repository
remote: error: is denied, because it will make the index and work tree inconsistent
remote: error: with what you pushed, and will require 'git reset --hard' to match
remote: error: the work tree to HEAD.
remote: error:
remote: error: You can set 'receive.denyCurrentBranch' configuration variable to
remote: error: 'ignore' or 'warn' in the remote repository to allow pushing into
remote: error: its current branch; however, this is not recommended unless you
remote: error: arranged to update its work tree to match what you pushed in some
remote: error: other way.
remote: error:
remote: error: To squelch this message and still keep the default behaviour, set
remote: error: 'receive.denyCurrentBranch' configuration variable to 'refuse'.

To amazon:/var/www/html/ProjectZero/

 ! [remote rejected] master -> master (branch is currently checked out)

error: failed to push some refs to 'amazon:/var/www/html/ProjectZero/'
Ikke
  • 99,403
  • 23
  • 97
  • 120
AngryGiraffe
  • 1
  • 1
  • 3
  • You cannot (by default) push into a non bare repository. Create a bare repository with `git init --bare`, then you can push to it. – knittl Mar 13 '14 at 10:24
  • @knittl, you can, I do it all the time, but not to the currently checked out branch. – Jonathan Wakely Mar 13 '14 at 10:25
  • @JonathanWakely: yes, you are right. But it's generally considered not good practice to push into any branch in a non-bare repo. – knittl Mar 13 '14 at 11:22

1 Answers1

0

! [remote rejected] master -> master (branch is currently checked out)

This means you are pushing to a non-bare repository, i.e. one that contains a working tree, and the branch you're pushing to is checked out.

This is rejected because if someone is actually working on the remote machine in that clone then the branch their working on would suddenly, mysteriously be modified.

To fix the problem either use a bare repository at the remote end, or login to the remote machine and check out a different (non-master) branch, so you can then push updates to master

Jonathan Wakely
  • 166,810
  • 27
  • 341
  • 521
  • Does this mean I need another branch in order to push to the master? Sorry I don't use Git very often. – AngryGiraffe Mar 13 '14 at 10:29
  • Either convert the remote to a bare repo (see http://stackoverflow.com/questions/2816369/git-push-error-remote-rejected-master-master-branch-is-currently-checked) or create a new branch on the remote (I often just do `git co -b tmp` to create a new branch and check it out) – Jonathan Wakely Mar 13 '14 at 10:30