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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-19 11:14:50  来源:igfitidea点击:

git - confusion over terminology, "theirs" vs "mine"

gitgit-branchgit-flow

提问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 -iand 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

oursand theirsis a somewhat confusing concept; exacerbated when performing a rebase:

ours并且theirs是一个有点令人困惑的概念;执行 rebase 时加剧:

When performing a merge, oursrefers to the branch you're merging into, and theirsrefers to the branch you are merging from. So if you are trying to resolve conflicts in the middle of a merge:

执行合并时,ours指的是您要合并theirs的分支,指的是您从中合并的分支。因此,如果您尝试解决合并过程中的冲突:

  • use oursto accept changes from the branch we are currently on
  • use theirsto accept changes from the branch we are merging into.
  • 用于ours接受来自我们当前所在分支的更改
  • 用于theirs接受来自我们正在合并的分支的更改。

That makes sense, right?

这是有道理的,对吧?

When rebasing, oursand theirsare inverted. Rebases pick files into a "detached" HEAD branch. The target is that HEAD branch, and merge-fromis the original branch before rebase. That makes:

重订ours并且theirs被反转。将选择文件变基到“分离”的 HEAD 分支。目标是那个 HEAD 分支,并且merge-from是 rebase 之前的原始分支。这使得:

  • --oursthe anonymous one the rebase is constructing, and
  • --theirsthe one being rebased;
  • --oursrebase 正在构建的匿名对象,以及
  • --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”。