git:如何获得合并冲突的“我们的,他们的,原创的”?

时间:2012-01-12 08:46:09

标签: git merge conflict

Git合并冲突通常如下所示:

<<<<<<< HEAD:file.txt
Code changed by A
=======
Code changed by B
>>>>>>> 77976da35a11db4580b80ae27e8d65caf5208086:file.txt

但是,我知道可以(使用一些git配置选项)来显示原始代码,而不仅仅是更改。类似的东西:

<<<<<<< HEAD:file.txt
Code changed by A
=======
Original code
=======
Code changed by B
>>>>>>> 77976da35a11db4580b80ae27e8d65caf5208086:file.txt

然而,我再也找不到这个选项......任何人都可以帮助我吗?

2 个答案:

答案 0 :(得分:29)

没关系,我刚刚找到了解决方案:

git config --global merge.conflictstyle diff3

实际上看起来像这样:

<<<<<<< HEAD:file.txt
Code changed by A
||||||| merged common ancestors
Original code
=======
Code changed by B
>>>>>>> 77976da35a11db4580b80ae27e8d65caf5208086:file.txt

答案 1 :(得分:3)

git checkout --conflict=diff3 -- file.txt

适用于单个调用。