git: How to get "ours, theirs, original" for merge conflicts?

4.1k views Asked by At

Git merge conflicts are shown like this usually:

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

However, I know it is possible (with some git config option) to also show the original code and not only the changes. Something like:

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

However, I can't find the option anymore. Can anyone help me out?

2

There are 2 answers

0
Jan Rüegg On BEST ANSWER

Never mind, I just found the solution:

git config --global merge.conflictstyle diff3

It actually looks like this:

<<<<<<< HEAD:file.txt
Code changed by A
||||||| merged common ancestors
Original code
=======
Code changed by B
>>>>>>> 77976da35a11db4580b80ae27e8d65caf5208086:file.txt
0
Ciro Santilli OurBigBook.com On
git checkout --conflict=diff3 -- file.txt

works for a single invocation.