git 颠倒变基

git rebase upside down

我正在尝试将我的本地功能分支变基到名为 'integration' 的远程分支。

所以我做到了-

git checkout feature
git rebase integration

但在我的冲突解决编辑器中,我看到底部的功能变化和顶部的 'integration',我认为这是颠倒的。我该如何解决?

看起来像-

<<<<<<< HEAD
<code from integration>
=======
<code from feature>
>>>>>>>

当您执行 rebase 时,分支会被切换,这就是为什么它们在您的冲突解决编辑器中看起来是倒置的。

根据the documentation

Note that a rebase merge works by replaying each commit from the working branch on top of the <upstream> branch.

因此您的本地分支 feature 提交应用于上游分支 integration

这会引起很多混乱,对此无能为力,只要记住在变基时分支会被反转。

解决冲突时,您的本地分支被称为 ours,而另一个分支被称为 theirs。在 rebase 冲突解决期间,ours 出现是他们的,theirs 出现是我们的。因此,如果您想了解有关此问题的更多信息,可以使用关键字 "ours"、"theirs" 和 "rebase" 在 SO 上搜索其他答案。一个很好的答案 is this one 我曾经回答过你的问题,如果我不够清楚的话,它在解释中更进一步。