the corner office : tech blog

a tech blog, by Colin Pretorius

« It's about the Ctrl-Space | Main | Is it just me? »

# 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

File under: programming : {2010.08.06 - 17:50}

Add a comment

Your name (mandatory):

Your email:
Your email address is not displayed
Your home page:

Comment (sorry, no HTML):

Remember details?
Yes No

meta

about
main blog

Categories

eclipse
java
linux
programming

RSS Feeds

rssfeed all posts
rssfeed all comments

Archives

2012.02
2012.01
2011.12
2011.11
2011.10
2011.09
2011.08
2011.07
2011.06
2011.05
2011.04
2011.03
2011.02
2011.01
2010.12
2010.11
2010.10
2010.09
2010.08
2010.07
2010.06
2010.05
2010.04
2010.03
2010.02
2010.01
2009.12
2009.11
2009.10
2009.09
2009.08
2009.07
2009.06
2009.05
2009.02
2009.01
2008.12
2008.11
2008.08
2008.07
2008.06
2008.05
2008.04
2008.03
2008.02
2008.01
2007.12
2007.11
2007.10
2007.09
2007.08
2007.07

© Colin Pretorius