My understanding is that the default branch of a cloned repository is to be whatever HEAD points to in the repo being cloned.
I now have a case where this is not tru
A bare repo has a HEAD
, too. That's what you get when you clone it.
From the git clone documentation:
Clones a repository into a newly created directory, creates remote-tracking branches for each branch in the cloned repository (visible using
git branch -r
), and creates and checks out an initial branch that is forked from the cloned repository's currently active branch.
The bit about "currently active branch" is referring to the remote's HEAD
revision.
If you want different behaviour, you can use --branch
or -b
:
--branch
-b
Instead of pointing the newly createdHEAD
to the branch pointed to by the cloned repository’sHEAD
, point tobranch instead. In a non-bare repository, this is the branch that will be checked out.
--branch
can also take tags and detaches theHEAD
at that commit in the resulting repository.