所以我和一个 friend 一直在做一个项目。 大多数时候 merge 是无痛的,因为我们通常在不同的领域工作。
最近我们越来越多地遇到彼此,造成令人讨厌的 merge (截止日期)。
因此,我们开始研究各种方法以查看 merge 的效果。我找到了一种使用 git diff 的方法:
git diff mybranch...hisbranch
这给出了很好的结果。问题是,因为它使用了最后一个共同的祖先,而且那个祖先越来越远, merge 中有很多垃圾,我们的任何一个分支都没有改变。
所以我想知道是否有一种方法可以准确地可视化 merge 的作用。
我试过:
git diff $(git-merge mybranch hisbranch) hisbranch
这似乎工作正常,但我想以另一种方式可视化 merge ,所以我尝试了:
git diff $(git-merge hisbranch mybranch) mybranch
但在这种情况下 git-merge: command not found
有谁知道获取两个分支的差异以显示 merge 将引入什么的好方法?也许突出冲突?
如果没有,是否有任何可视化工具可以让人们手动进行提交,这样人们就可以选择最好的代码版本。
最佳答案
还有其他方法可以可视化会发生什么,但我发现最简单的方法是 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
,或者如果我想提交 merge ,我会正常进行 git commit
.
关于git diff 查看 merge 会引入什么,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11727102/