I know this can be done on the Admin page of a repository. Another default branch can be set there. And that would be the answer of this question.
But I discovered (maybe a bug?) the following. If your master branch and develop branch are exactly the same, than a git clone will not clone the default "develop" branch, but still "master"!! If you commit something to the develop branch, remove your clone and than clone again, you will get the develop branch!
Is this Git behaviour or Github? And can this be fixed to set it ALWAYS to develop?
If the develop branch is default, pull requests etc. would default to the correct branch. However, develop might be broken from time to time. If the master branch is default, every visitor would be presented with the code of the latest stable release version.
I just tested it with local repo, and while the HEAD
of my first repo test
is "develop
":
C:\Users\VonC\Documents\GitHub\test>git symbolic-ref HEAD
refs/heads/develop
... the name of the default branch cloned in test1
is master
!
C:\Users\VonC\Documents\GitHub\test1>git branch -a
* master
remotes/origin/HEAD -> origin/master
remotes/origin/develop
remotes/origin/master
See "How do I change a Git remote HEAD
to point to something besides “master
”":
From the cloned repo perspective, HEAD
on the remote origin repo references both master
and develop
:
C:\Users\VonC\Documents\GitHub\test1>git ls-remote origin
c215dd28ea8bf9b0c6b522c784b70bbbb3e858a5 HEAD
c215dd28ea8bf9b0c6b522c784b70bbbb3e858a5 refs/heads/develop
c215dd28ea8bf9b0c6b522c784b70bbbb3e858a5 refs/heads/master
And the order for determining the default branch of a cloned repo is:
HEAD
referencesrefs/heads/master
and that exists -> you get a local branch calledmaster
, starting fromorigin/master
HEAD
referencesrefs/heads/anotherBranch
and that exists -> you get a local branch called anotherBranch, starting fromorigin/anotherBranch
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With