On Mon, 14 Feb 2011 08:34:05 -0800 (PST)
Veloz <michaelve...@gmail.com> wrote:

[...]
> I did a little testing whereby a setup a bare repo on my machine and
> added an origin to my source repo to point to this bare repo. Then I
> checked out some branch on my source repo, say "desiredbranch" tried
> to do a "push neworigin desiredbranch".
> 
> The push worked fine but then when I cloned this newly populated bare
> repo (to see how a working repo would look like, based in the newly
> populated bare repo) I I got this message:
> 
> warning: remote HEAD refers to nonexistent ref, unable to checkout.
[...]

Explanation: the "HEAD" ref in a bare repo points to a physical ref
(usually a branch) which, when someone clones that repo, should be made
the default in the resulting clone.
When you initialize a bare repo its HEAD ref is set to point to the
"master" branch but the branch itself does not exist (obviously).
When you do
$ git push neworigin desiredbranch
Git creates "desiredbranch" in the remote repo, but its HEAD ref
remains pointing to a non-existing "master" branch.

So, there are two ways to fix the situation:
at first, do
$ cd /path/to/that/bare/repo
and then either
$ git branch -m desiredbranch master
or
$ git update-ref HEAD refs/heads/desiredbranch
and then re-clone the bare repo.

The first method simply renames "desiredbranch" to "master", the second
updates the HEAD ref to point to "desiredbranch".

Another way would be to re-create the bare repo and push your desired
branch like this:
$ git push neworigin desiredbranch:master
so that it ends up being named "master" in the repote repo.

-- 
You received this message because you are subscribed to the Google Groups "Git 
for human beings" group.
To post to this group, send email to git-users@googlegroups.com.
To unsubscribe from this group, send email to 
git-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/git-users?hl=en.

Reply via email to