git - 术语混淆,“他们的”与“我的”
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/31817210/
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
git - confusion over terminology, "theirs" vs "mine"
提问by CaptSaltyHyman
I'm completely confused about what mine vs theirs means. In this specific case, I've got a feature branch where I just squashed about 80 commits via rebase -i
and am merging this back into develop
. I got a few conflicts, and I just want to use whatever code is on my feature branch. I tried "mine" but that actually seemed to do the opposite.
我对我的和他们的意味着什么完全感到困惑。在这种特定情况下,我有一个功能分支,我只是通过压缩大约 80 个提交rebase -i
并将其合并回develop
. 我遇到了一些冲突,我只想使用我的功能分支上的任何代码。我尝试了“我的”,但实际上似乎相反。
Could someone shed some light on this terminology?
有人可以解释一下这个术语吗?
回答by Keith
ours
and theirs
is a somewhat confusing concept; exacerbated when performing a rebase:
ours
并且theirs
是一个有点令人困惑的概念;执行 rebase 时加剧:
When performing a merge, ours
refers to the branch you're merging into, and theirs
refers to the branch you are merging from. So if you are trying to resolve conflicts in the middle of a merge:
执行合并时,ours
指的是您要合并到theirs
的分支,指的是您从中合并的分支。因此,如果您尝试解决合并过程中的冲突:
- use
ours
to accept changes from the branch we are currently on - use
theirs
to accept changes from the branch we are merging into.
- 用于
ours
接受来自我们当前所在分支的更改 - 用于
theirs
接受来自我们正在合并的分支的更改。
That makes sense, right?
这是有道理的,对吧?
When rebasing, ours
and theirs
are inverted. Rebases pick files into a "detached" HEAD branch. The target is that HEAD branch, and merge-from
is the original branch before rebase. That makes:
当重订,ours
并且theirs
被反转。将选择文件变基到“分离”的 HEAD 分支。目标是那个 HEAD 分支,并且merge-from
是 rebase 之前的原始分支。这使得:
--ours
the anonymous one the rebase is constructing, and--theirs
the one being rebased;
--ours
rebase 正在构建的匿名对象,以及--theirs
一个被重新定位;
I.e., rebasing replays the current branch's commits (one at a time) on top of the branch that we intend to rebase with.
即,rebase 重放当前分支的提交(一次一个)在我们打算rebase 的分支之上。
回答by mipadi
"Ours" (and "mine") refer to the currentbranch; "theirs" refers to the branch being merged in. It sounds like you actually wanted to use "theirs".
“我们的”(和“我的”)指的是当前的分支;“theirs”指的是被合并的分支。听起来您实际上想使用“theirs”。