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

2

27

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?

Charcoal answered 12/1, 2012 at 8:46 Comment(0)
C
37

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
Charcoal answered 12/1, 2012 at 8:47 Comment(0)
A
4
git checkout --conflict=diff3 -- file.txt

works for a single invocation.

Arrival answered 15/9, 2014 at 9:36 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.