2

I am new to Git.

Git follows the non-linear DAG model. So there can be many nodes along many work paths. When I clone a remote git repo like below:

git clone https://xxx.git

Which node in the DAG do I get checked out as my local working tree?

I think it should be some kind of latest node. But since DAG model can have many branches each pointing to the tip of a certain development path, which one do I get when cloning? The HEAD symbolic pointer on the server? If so, who decides that HEAD?

smwikipedia
  • 61,609
  • 92
  • 309
  • 482
  • It could be master or no HEAD without `-b `. In the latter case, you need to run `git checkout` after clone is done. – ElpieKay May 29 '16 at 16:38
  • 1
    Note that you may specify a symbolic name when cloning, "git clone -b *name* *url*", to override the default. This name can be any name that Git sees at the start of the clone process, but not a raw hash. See VonC's answer for the rest. – torek May 29 '16 at 20:12

1 Answers1

4

If so, who decides that HEAD?

See "Change a Git remote HEAD to point to something besides master"

By default, HEAD (on the remote repo side) references master, but some git repo hosting services (GitHub, GitLab, BitBucket) propose to change the default branch.
That effectively changes the symbolic-ref that is HEAD, as in git symbolic-ref:

git symbolic-ref HEAD refs/head/anotherBranch

If you point a default branch (on a remote repo), and then later delete that branch, any clone of that remote repo would fail and complain.

Community
  • 1
  • 1
VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
  • Thx. So, it IS the HEAD that get checked out as my local working tree. And btw, if the default branch `origin\master` is so critical, why not make it un-deletable? – smwikipedia May 29 '16 at 15:19
  • @smwikipedia branches are just transient markers in that DAG: see http://stackoverflow.com/a/24404577/6309. And master is just a naming convention. – VonC May 29 '16 at 15:23