Why is there a `remotes/origin/HEAD -> origin/master` entry in my `git branch -l -a` output?

后端 未结 2 1266
清酒与你
清酒与你 2020-12-07 09:35

I don\'t understand the second line in the output to git branch -l -a: remotes/origin/HEAD -> origin/master.

git branch -l -a
*          


        
相关标签:
2条回答
  • 2020-12-07 10:30

    You can use git remote set-head origin -d to delete the origin/HEAD symbolic ref, or git remote set-head origin -a to query the remote and automatically set the origin/HEAD pointer to the remote's current branch.

    The origin/HEAD reference is optional. It only acts as a syntactic shortcut: If it exists and points to origin/master, you can use specific simply origin where you would otherwise specify origin/master.

    The git remote(1) man page describes this:

    set-head

    Sets or deletes the default branch (i.e. the target of the symbolic-ref refs/remotes//HEAD) for the named remote. Having a default branch for a remote is not required, but allows the name of the remote to be specified in lieu of a specific branch. For example, if the default branch for origin is set to master, then origin may be specified wherever you would normally specify origin/master.

    0 讨论(0)
  • 2020-12-07 10:33

    No, no need to clean up: it is the symbolic branch referenced by your remote repo.
    When you clone your repo, you will be by default on the branch referenced by remotes/origin/HEAD.

    See also:

    • "Git: Correct way to change Active Branch in a bare repository?"
    • "How do I change a Git remote HEAD to point to something besides “master”"
    • "How does origin/HEAD get set?"

    Note: you need to use git branch --list (or git branch), not git branch -l.

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