Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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 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... anyone can help me out?

like image 708
Jan Rüegg Avatar asked Jan 12 '12 08:01

Jan Rüegg


People also ask

How do you reset merge conflicts?

You can use the git reset --merge command. You can also use the git merge --abort command. As always, make sure you have no uncommitted changes before you start a merge.

How do you check if there is any merge conflict?

To see the beginning of the merge conflict in your file, search the file for the conflict marker <<<<<<< . When you open the file in your text editor, you'll see the changes from the HEAD or base branch after the line <<<<<<< HEAD .

How do you resolve a merge conflict on the same branch?

To fix this situation, you need to create new commits that mimic those on the branch. The easiest way to do that is with git rebase -f . Now you can merge branch in again.


1 Answers

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 
like image 74
Jan Rüegg Avatar answered Sep 22 '22 21:09

Jan Rüegg