On 03/09/2014 07:46 AM, Torsten Bögershausen wrote:
After creating a local repository with these two branches, and a server 
repository with git init --bare, and pushing the two branches:
> > git remote add originfoo@bar:~/path/test.git
>  git push origin master-g
>  git push origin master-x
> > everything seems fine, but cloning:
>  git clonefoo@bar:~/path/test.git
>  terminates with a warning: remote HEAD refers to nonexistent ref, unable to 
This is because Git is trying to be nice:
When you clone, it tries to checkout a branch for you.

What happens when you only have 1 branch, lets say master-x?
If I clone the bare repo here, with only 1 branch, this branch
is automatically checked out (tested on

What happens when you have 2 branches on the server?
Git really can not make a decision which one is the right one to check out for
you, so if you have 2 branched like "master" and "develop", it checks out the
"master" branch for you.

But if you have "master-x" and "master-g" then Git has no clue, which one could
be you favorite one (and neither have I)
The problem is on the server repo, the cloned repo is just a consequence. After initializing the server repo and pushing two branches master-g and master-x there is no master branch. Therefore the HEAD file should not point to a master branch that does not exist: ref: refs/heads/master

It could point to master-g (the first branch to be pushed) or master-x (the last branch to be pushed), depending of the criterion used by git, but pointing to something that does not exist seems weird and is the cause of the further complaints when the whole repository is cloned...

I forgot to say that the git version is in both the initial repo and the server repo (probably this issue was fixed in newer versions?)

As I said, editing directly the HEAD text file on the server, and replacing master by master-g (or master-x) seems to solve the problem. My question is: is that enough? or shall I expect further issues down the road?

Thank you very much,

What does "git branch" say?
(I think nothing)
What does "git branch -r" say?
(I think "origin/master-g" and "origin/master-x")

To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to