git mergetool 无法正确进行三向 merge

标签 git git-rebase meld

我已经开始使用 meld 作为我的 merge.tool。到目前为止一切正常,但我今天在三向 merge 方面遇到了问题。

在 MyBranch 的 file.txt 中,我添加了代码 ME:

A
B
ME
D
E

同时,master 添加了代码 THEM_1THEM_2。我运行 git rebase master 。这是 rebase 暂停时 file.txt 的样子:

  A
  THEM_1
  B
<<<<<<< HEAD
  ME
||||||| merged common ancestors
=======
  THEM_2
>>>>>>> My patch name
  D
  E

THEM_2 在 merge 中应该位于 ME 之前,因此明显的 merge 是

A
THEM_1
B
THEM_2
ME
D
E

但是当我运行打开 meld 的 git mergetool 时,三个版本都没有 THEM_1。给出了什么?

最佳答案

我只是想重现你的情况。

如果我做git checkout me; git merge 他们的; git mergetool -t meld,我得到以下内容:

local | merge | remote
------+-------+-------
A     | A     | A
B     | B     | THEM_1
ME    | D     | B
D     | E     | THEM_2
E     |       | D
      |       | E

(这正是两个分支和中间公共(public)父分支的内容。)

如果我做git checkout me; git rebase 他们的; git mergetool -t meld,我得到与本地和远程交换相同的结果。

在这两种情况下,您只需单击即可添加 THEM_1。对于ME/THEM_2处的冲突,您可以通过单击添加一侧,但必须在中间框架中手动添加另一侧。

看看kdiff3,它是解决 merge 冲突的一个更好的工具。

请注意,如果要重新设置多个提交的基础,则具有冲突的重新设置基础往往会很棘手。

关于git mergetool 无法正确进行三向 merge ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19598520/

相关文章:

Git Rebase 冲突 : Who is HEAD?

Ubuntu 融合 : No GSettings schemas are installed on the system

git - 如何解决与 Github API merge 的冲突

git write-tree 写树失败

gitcherry-pick : how consider only lines modified by the commit (i. e.,不是周围的上下文)?

Git 设备上没有剩余空间

git - 将一个分支中的所有缺失提交 rebase /复制到当前分支之上

git - SourceTree-git : fatal: remote error: Repository not found

git - 从 EC2 ubuntu 推送到 github

java - 将 maven pom.xml 上传到 Git 存储库?