Reputation: 16510
I am trying to prepare a Git demo on my Windows laptop, which is off line. Using Git Bash, I created a small project in /c/demo/git-demo/ and did a git init, and added file test.txt and committed it.
Then in another shell, I did
cd /c/demo
git clone /c/demo/git-demo git-demo-clone
cd git-demo-clone
ls -l
That works fine, I see test.txt.
Then I modify the file from git-demo-clone and do a commit, which again works fine.
However when I next do git push from git-demo-clone, I get an error
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: is denied, because it will make the index and work tree inconsistent
remote: with what you pushed, and will require 'git reset --hard' to match
remote: the work tree to HEAD
What to do?
Upvotes: 1
Views: 20
Reputation: 30277
That happens because in the other repository, the branch that is checked out is the branch you are trying to push (which is normally not ok because it would be like moving someone's rug from under their feet while they are working on a given branch). You could avoid it 4 ways:
git checkout --detach
)Upvotes: 2