git refusing to update checked out branch
I created a local clone of my main (in git-speak 'origin') repo for one of my projects, and after committing locally and then doing a git push
I got this 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: 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.
After reading this it started to make sense. My main/origin repo looked like a first-class, in-use repo, and git thinks that since it might be an active repo, pushing to it would be a bad idea.
The solution was in the post above. Step 1 is to change to the directory containing the origin repo and execute
git config --bool core.bare true
With that done, git knows that the repo is bare, and you can push to it.
Step 2 would be to delete of any checked out code in the origin directory so that all that directory contains is the .git
directory.
Update: a good way to do a bunch of directories at once is something like this:
for f in `ls`; do cd $f && git config --bool core.bare true && cd ..; done
{2010.08.06 16:50}