4

所以我和一个朋友一直在做一个项目。大多数时候合并是无痛的,因为我们通常在不同的领域工作。

最近,我们越来越多地遇到彼此,造成令人讨厌的合并(截止日期)。

所以我们开始研究方法来看看合并会做什么。我找到了一种使用 git diff 的方法:

git diff mybranch...hisbranch

这给出了很好的结果。问题是,因为它使用了最后一个共同的祖先,并且那个祖先越来越远,所以合并中有很多垃圾在我们的任何一个分支中都没有改变。

所以我想知道有没有一种方法可以准确地可视化合并会做什么。

我试过了:

git diff $(git-merge mybranch hisbranch) hisbranch

这似乎工作正常,但我想以另一种方式可视化合并,所以我尝试了:

git diff $(git-merge hisbranch mybranch) mybranch

但在这种情况下git-merge: command not found

有谁知道获得两个分支差异的好方法,显示合并会引入什么?也许突出冲突?

如果没有,是否有任何可视化工具允许手动进行提交,因此可以选择最好的代码版本。

4

1 回答 1

7

还有其他方法可以可视化会发生什么,但我发现最简单的是git merge --no-commit. 从手册页:

--commit, --no-commit
Perform the merge and commit the result. This option can be used to override --no-commit.

With --no-commit perform the merge but pretend the merge failed and do not autocommit, to give the user a chance to inspect and further tweak the merge
result before committing.

基本上,我只是发布git merge --no-commit <branch>并检查结果。如果我不喜欢它们,我会发出git merge --abort,或者如果我想提交合并,我会正常进行git commit.

于 2012-07-30T20:31:13.577 回答