我的 git 分支在 Sourcetree 中显示“origin/master”和“origin/HEAD”,我不知道如何合并两者
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/11527287/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
My git branch is showing 'origin/master' and 'origin/HEAD' in Sourcetree and I don't know how to merge the two
提问by Zachary Abresch
I recently merged a branch I was working on with the 'master' branch. I must have (still kind of a git n00b) done something when pushing or pulling that created both an origin/master
and an origin/HEAD
branches. Unfortunately, I didn't keep a record of what commands I ran that did this. Currently, my team has a bunch of code in their master copies that I'm not getting when I check out the project (even if I clone
to a new location).
我最近将我正在处理的分支与“主”分支合并。我必须(仍然是一个 git n00b)在推或拉时做了一些事情来创建一个origin/master
和一个origin/HEAD
分支。不幸的是,我没有记录我运行了哪些命令来执行此操作。目前,我的团队在他们的主副本中有一堆代码,我在检查项目时没有得到这些代码(即使我clone
到了一个新位置)。
Here's a screenshot of what Sourcetree is showing:
这是 Sourcetree 显示的屏幕截图:
I really need to get this resolved so I can keep working so any help will be greatly appreciated.
我真的需要解决这个问题,这样我才能继续工作,所以任何帮助都将不胜感激。
回答by Gabriel
It is just a pointer to master, a symbolic link if you wish. You can safely delete it by doing the following in a terminal (or git bash/cygwin for windows users):
如果您愿意,它只是一个指向 master 的指针,一个符号链接。您可以通过在终端(或 Windows 用户的 git bash/cygwin)中执行以下操作来安全地删除它:
- navigate to your repository
- execute:
git remote set-head origin -d
- 导航到您的存储库
- 执行:
git remote set-head origin -d
now it should be gone:
现在它应该消失了:
$ git branch -r
origin/master
回答by Mark Longair
The branches you see that begin with origin/
are so-called "remote-tracking braches". They tell you the position of the branches in the repository origin
the last time git fetched from that repository.
您看到的以开头的分支origin/
是所谓的“远程跟踪分支”。它们会告诉您origin
上次从存储库中提取 git 时分支在存储库中的位置。
It's nothing to worry about - this is actually helpful information. If you think those branch positions are out of date, you can run:
不用担心 - 这实际上是有用的信息。如果您认为这些分支职位已过时,您可以运行:
git fetch origin
... to update them.
...更新它们。
In any repository, HEAD
is special kind of ref (a "symref") that represents the current branch (or current commit, if you're not on a particular branch).
在任何存储库中,HEAD
都有一种特殊的 ref(“symref”)代表当前分支(或当前提交,如果您不在特定分支上)。
You can see in the diagram that your master
branch is actually one commit ahead of origin/master
, so if your colleagues have been pushing to master
in origin
and you ran git fetch origin
(or something equivalent) recently, you already have all their work. However, they will be missing out on your commit until you push that.
您可以在图中看到你的master
分支实际上一个承诺提前为origin/master
,所以如果你的同事一直在推动以master
中origin
和您运行git fetch origin
(或等效的东西)最近,你已经有了所有的工作。但是,在您推送之前,他们将错过您的提交。
You say:
你说:
Currently, my team has a bunch of code in their master copies that I'm not getting when I check out the project (even if I clone to a new location).
目前,我的团队在他们的主副本中有一堆代码,当我检查项目时我没有得到这些代码(即使我克隆到一个新位置)。
If that's the case, they're probably pushing to a different branch, a different repository, or they haven't pushed their work at all.
如果是这种情况,他们可能正在推送到不同的分支、不同的存储库,或者他们根本没有推送他们的工作。