How to set develop branch as default in Github instead of master?

前端 未结 1 1298
庸人自扰
庸人自扰 2021-02-20 06:43

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 (mayb

相关标签:
1条回答
  • 2021-02-20 07:30

    This is a git "feature"

    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 references refs/heads/master and that exists -> you get a local branch called master, starting from origin/master
    • HEAD references refs/heads/anotherBranch and that exists -> you get a local branch called anotherBranch, starting from origin/anotherBranch
    0 讨论(0)
提交回复
热议问题