Why is “origin/HEAD” shown when running “git branch -r”?

后端 未结 7 1300
故里飘歌
故里飘歌 2020-11-28 01:16

When you run git branch -r why the blazes does it list origin/HEAD? For example, there\'s a remote repo on GitHub, say, with two branches: master a

相关标签:
7条回答
  • 2020-11-28 02:05

    You're right that pushing to dedicated remote repos work much better when they are 'bare', that is, when they don't have working directories. Git's architecture is designed for updating by patches or pull (fetch), which makes sense in a distributed VCS. As the docs say somewhere, pushing to a branch which is currently checked out can result in "unexpected results".

    The HEAD is part of the requirements for a valid repository. Git Repository Layout says, in part:

    HEAD
    
    A symref (see glossary) to the refs/heads/ namespace describing the currently active  
    branch. It does not mean much if the repository is not associated with any working tree  
    (i.e. a bare repository), but a valid git repository must have the HEAD file; some  
    porcelains may use it to guess the designated "default" branch of the repository  
    (usually master). It is legal if the named branch name does not (yet) exist.
    

    So you're going to see HEAD as part of the branch list, even if "it does not mean much..."

    0 讨论(0)
提交回复
热议问题