-1

i edited the file and git add filename followed by git commit -m 'message' , and i type git push, it comes out this error. how do i solve this?

Master:disrupreneurs shaunstanislaus$ git push
Counting objects: 11, done.
Delta compression using up to 8 threads.
Compressing objects: 100% (6/6), done.
Writing objects: 100% (6/6), 1.71 KiB, done.
Total 6 (delta 3), 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 ec2-user@www.disrupreneurs.org:disrupreneurs
 ! [remote rejected] master -> master (branch is currently checked out)
error: failed to push some refs to 'ec2-user@www.disrupreneurs.org:disrupreneurs'
Shaun Stanislaus
  • 511
  • 1
  • 6
  • 20
  • have you checked this? http://stackoverflow.com/questions/8985782/git-push-fails-refusing-to-update-checked-out-branch-refs-heads-master – Trent Earl Dec 06 '12 at 02:37

1 Answers1

2

There are two flavors of git repository:

  • bare bare repository are used to share the code among developers. You normally will clone from it and push to it.

  • non-bare non-bare repos are used to do the coding work. They are generally clone from a bare repo for which you generally will push your commits

The repo you are trying to push to is not a bare repo, and thus is has a checked out branch. Newer git versions will not allow you to push to a current checked out branch of a non bare repo as it would cause you to overwrite someone else works as non-bare repo are supposed to be the working repo of someone else.

So you have tree option: - do what the message says :

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.

  • checkout another branch on the target repo
  • or the best thing to do is to use a bare repo (git clone --bare) to be the shared repo.
André Oriani
  • 3,553
  • 22
  • 29