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

后端 未结 7 1349
故里飘歌
故里飘歌 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 01:45

    I was under the impression that dedicated remote repos (like GitHub where no one will ssh in and work on that code, but only pull or push, etc) didn't and shouldn't have a HEAD because there was, basically, no working copy. Not so?

    I had the exact same impression like you said.

    And I even can not delete that origin/HEAD remote-tracking branch cloned from github by doing

    git branch -d -r origin/HEAD
    

    This had no effect.

    Can some one tell me how I can delete that origin/HEAD remote-tracking branch?

    update

    Though I did not found why there is a origin/HEAD created when clone from github, I find a way to delete it.

    The new version of git provide

    git remote set-head  -d
    

    to delete the useless HEAD pointer of remote-tracking branch.

    And we can also change the dumb default name 'origin' to whatever we want by using

    git remote rename origin 
    

    Hope this can help. :)

提交回复
热议问题