Edit: I'm not sure I answered the intended question (having followed the link to the other question since then). If you're wondering: how did the remote repo's HEAD
get changed to identify something unusual (if indeed it did), the answer depends on who uses the remote repo, and how. If the remote repository is used for git checkout
operations (e.g., to deploy stuff even from a bare repository), the HEAD
entry can be updated by a checkout.
When you do an initial git clone
, you specify a branch with -b
, and git checks that out.
If you don't specify a branch with -b
(most people don't), git still picks something to check out. What it picks to check out, is a bit tricky.
After you've cloned, you can run git ls-remote origin
. You will see something like this:
6c4ab27f2378ce67940b4496365043119d7ffff2 HEAD
32f56600bb6ac6fc57183e79d2c1515dfa56672f refs/heads/maint
6c4ab27f2378ce67940b4496365043119d7ffff2 refs/heads/master
9eef2c89753895da807c936ff1ba3a255c8370c9 refs/heads/next
0c53c9308fc7349ea93fd96ce7bbff7a8d0dfa41 refs/heads/pu
3d84dcf9136e737c8a8d10b7954928df732dadca refs/heads/todo
(this is from running git ls-remote
on the git repository itself just now). Note that there is a raw SHA-1 listed for HEAD
, not the symbolic reference, even though HEAD
on the remote is almost certainly a symbolic reference (specifically to refs/heads/master
).
Your local git compares the SHA-1 here to the SHA-1s for all the refs/heads/
(branches). If exactly one matches, as is the case here, it assumes you wish to check out a local branch that tracks the corresponding remote branch.
If more than one SHA-1 matches, git just picks one of them.
If none match, I'm not actually sure what git does.