Recently I enabled diff3 and it's much easier to resolve conflict now.
Previously in some cases I had to check the log to see why people did this and that to do the merge. But with diff3 the information is displayed all in one place
<<<<<<< HEAD
THIS IS USEFUL
||||||| merged common ancestors
This is useful
=======
This is really useful
>>>>>>> c2392943.....
From that we can easily see that the result should be "THIS IS REALLY USEFUL"
I wonder if there is any downside to diff3? Why it is not the default behavior of git?
For other readers (and from this article):
git has an option to display merge conflicts in
diff3
format (by default it only displays the two files to be merged). You can enable it like so:
git config --global merge.conflictstyle diff3
There's really no reason you shouldn't enable the diff3 style, because you frequently need the ancestor to determine what the correct merge is.
This was introduced fairly early (2008), and I supose it isn't the default, because a default unix diff isn't display as a 3-way diff.
As mentioned in this thread, if you want to run this command without setting the config, so that you can switch between normal diffs and diff3s easily, this is possible in one specific case:
If a conflict is marked in the index (i.e., the state you are in after a conflicted merge, but before you mark a path as resolved), you can do:
git checkout --conflict=diff3 <path...>
Note that that is actually checking out the index contents into the working tree, so any edits you may have made to the conflicted working tree copy will be overwritten.
来源:https://stackoverflow.com/questions/27417656/should-diff3-be-default-conflictstyle-on-git