git diff 查看 merge 会引入什么

标签 git version-control merge git-merge

所以我和一个 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/

相关文章:

git - 支持 Git 的开源 IDE

ios - XCode 中的源代码控制是一场噩梦——任何人都可以提供建议吗?

git - 在这些场景下使用 git cherry-pick 是否合适?

git - 使用 Git 管理大型二进制文件

git - 如何确定git中的最后一个 merge 分支?

node.js - 列出git中master和当前分支之间的所有文件?如果有任何 Node 包可以将结果推送到数组 :) 中,那就太好了

git - 推送导致大量对象推送的更改

Python递归合并排序不起作用

r - 删除 R 中的冗余列

git - 将单个分支历史转换为许多较小的 merge 分支