Take the 2-minute tour ×

Have a remote git bare repo that onto which I've pushed a branch from one machine, and pulled to another machine.

Made some changes on the other machine, trying to push those changes back to the remote bare repo, and I get the 'receive.denyCurrentBranch' error.

What's going on?

This isn't supposed to happen on a bare repo - there's nothing checked out on it.

The branches as seen from machine 2 are:

remotes/origin/HEAD -> origin/dev1

'Fix' is the current branch on both dev machines.

When I originally pulled that branch on machine 2, I did:

git pull
git checkout -b Fix origin/Fix

I'm suspicious of the first 'remotes' line - seems that the HEAD should be pointing to my current branch, but it isn't. Think I'm missing something, here..

Update 1 I merged the 'Fix' branch down to the dev1 branch, and then pushd the 'dev1' branch - that worked ok (I was about to do that, anyway).

So, that was a workaround, but I think the real problem was that the HEAD wasn't tied to the current branch ('Fix'), but to an inactive branch ('dev1'). I'm not sure how to change the head on the remote repo?

share|improve this question
Somebody please correct me if I'm wrong, but bare repositories are not supposed to even have a HEAD. That would indicate that there is a working directory, and the HEAD points to the commit it is based off of... Are you certain the remote repo is bare? –  Jonathan Oct 26 '10 at 17:08
Pretty certain. There's no checked out project, and all the 'git' files are at the top level directory of the repository. –  rickb Oct 27 '10 at 20:34
Jonathan, a bare Git repository does have a HEAD, but no default workspace. A workspace can still exist for a bare repository, but you must inform Git where it exists using environment variable GIT_WORK_TREE or Git option --work-tree and the location of the repository using environment variable GIT_DIR or option --git-dir. –  Derek Mahar Apr 5 '11 at 15:18
could it be the case that theres already a fix/whatever branch and this conflicts in creating a fix branch on origin? –  eckes Aug 18 '12 at 21:06

1 Answer 1

From the Machine 2, to upload refs from local repository to remote repository you can use explicit refs in the push command:

git push origin Fix:refs/heads/Fix

After that, in the Machine 1, you should use the fetch command to obtain the remote refs

git fetch

In the list of branches (git branch -a), you will found origin/Fix (or remotes/origin/Fix), you can browser the content of the remote branch directly by using the checkout command:

git checkout origin/Fix

Make your changes, commit, etc... and then push it using the same command used in machine 2:

git push origin Fix:refs/heads/Fix

To track the branch (this is, create a local branch that "points" the remote branch, use the checkout command with --track option):

git checkout --track -b Fix origin/Fix

Then, you can work on local branch Fix and do push and pull without other arguments

git pull
git commit
git push
share|improve this answer

Your Answer


