本文介绍了为什么是“起源/头部"?运行“git branch -r"时显示?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当你运行 git branch -r 时,为什么 blazes 会列出 origin/HEAD?例如,GitHub 上有一个远程仓库,有两个分支:master 和 awesome-feature.如果我执行 git clone 来抓取它,然后进入我的新目录并列出分支,我会看到:

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

或者它的任何顺序(alpha?我在伪造这个例子是为了保密一个无辜回购的身份).那么 HEAD 的业务是什么?是不是最后一个 push 的人在推送时让 HEAD 指向了什么?那不会总是他们pushed 的东西吗?HEAD 四处走动……我为什么要在意别人的 HEAD 在另一台机器上指向什么?

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 pushed? HEADs 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!

我的印象是专用的远程存储库(例如 GitHub,没有人会通过 ssh 进入并处理该代码,而只会拉或推等)没有也不应该有 HEAD,因为有,基本上,没有工作副本.不是吗?

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 是正确的.

在 git 中,您可以选择默认检出哪个分支(即克隆时).默认情况下,origin/HEAD 将指向那个.

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.

在 GitHub 上,您可以在管理设置中更改此你的 GitHub 仓库.您也可以通过

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

或通过

git remote set-head origin -d

示例.查看切换分支"下拉菜单.trunk 被检查,所以 origin/HEAD 跟在 trunk 后面.

Example. Look at the 'Switch Branches' drop-down. trunk is checked, so origin/HEAD follows trunk.

这篇关于为什么是“起源/头部"?运行“git branch -r"时显示?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-24 12:05