为什么“起源/ HEAD”在运行“git branch -r”时显示? [英] Why is "origin/HEAD" shown when running "git branch -r"?
问题描述
当你运行 git branch -r
时,为什么它会列出 origin / HEAD
?例如,GitHub上有一个远程回购,比如两个分支:master和awesome-feature。如果我使用 git clone
来抓取它,然后进入我的新目录并列出分支,我可以看到:
< pre $
$ git branch -r
origin / HEAD
origin / master
origin / awesome-feature
或者它会在什么顺序(阿尔法?我假装这个例子保持无辜的回购秘密的身份)。那么,什么是 HEAD
业务?最后一位 push
的最后一个人在他们的 HEAD
指向了什么时候被指向?那不会总是它们是什么吗? push
ed? HEAD
s左右移动...为什么我在意别人的 HEAD
指向另一台机器?
我正在处理远程跟踪等问题,所以这是一个令人困惑的问题。编辑:我的印象是专用的远程回购(像GitHub,其中没有人会ssh和工作的代码,但只拉或推,等等)没有,也不应该有头,因为基本上没有工作副本。不是这样吗?
@robinst 是正确的。
在git中,您可以选择默认检出哪个分支(即,克隆时)。默认情况下, origin / HEAD
会指向它。
在GitHub上,您可以在管理设置中为您的GitHub仓库更改此项。你也可以通过命令行通过
git remote set-head origin trunk
$ c
或者通过 $ b
git remote set-head origin -d
示例。看看'Switch Branches'下拉菜单。选中 trunk
,所以 origin / HEAD
跟在 trunk
之后。
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 and awesome-feature. If I do git clone
to grab it and then go into my new directory and list the branches, I see this:
$ git branch -r
origin/HEAD
origin/master
origin/awesome-feature
Or whatever order it would be in (alpha? I'm faking this example to keep the identity of an innocent repo secret). So what's the HEAD
business? Is it what the last person to push
had their HEAD
pointed at when they pushed? Won't that always be whatever it was they push
ed? HEAD
s move around... why do I care what someone's HEAD
pointed at on another machine?
I'm just getting a handle on remote tracking and such, so this is one lingering confusion. Thanks!
EDIT: 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?
解决方案 @robinst is correct.
In git, you can select which branch is checked out by default (i.e. when you clone). By default, origin/HEAD
will point at that.
On GitHub, You can change this in the Admin settings for your GitHub repo. You can also do it from the command-line via
git remote set-head origin trunk
or delete it altogether via
git remote set-head origin -d
Example. Look at the 'Switch Branches' drop-down. trunk
is checked, so origin/HEAD
follows trunk
.
这篇关于为什么“起源/ HEAD”在运行“git branch -r”时显示?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!