Saturday, August 7, 2010

Local git setup error

Recently I decided to check GIT. I am old fan of Tortoise tools and I decided to start with TortoiseGit. It is nice tool with familiar interface.

I am a little familiar with Mercurial and heard that they are quite similar in concepts. So I started by creating repository by command “Git create repository here”.
Then I created “Git Clone” of my repository in new folder. Then I started to play and created new files and commited changes. But then, when I tried to push my changes to master repository I got big ugly error:

git.exe push    "origin" master:master

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 C:\########
 ! [remote rejected] master -> master (branch is currently checked out)
error: failed to push some refs to 'C:\########'

This was quite confusing and error is not helping much. Also this scenario was working nicely with Mercurial, so I was really confused. But after some googling I found really nice article about git at, and it is explained nicely how to create repository that can be used with “push”. You just have to create it with

git --bare init --shared

It is really strange that there is no any option that can be set while creating repository and you still have to do it command line way. But issue was solved.