Solving git merge conflicts using .rej files

If you are used to solve merge conflicts in the good old way with .rej files, there's no configuration flag whatsoever in git to allow you doing that. However you could install your own merge driver to act the way you want.

Same merge conflict in 3way diff versus .rej file:

Using 3way diff.
Using .rej files.

Add those things to your ~/.gitconfig:

    attributesfile = ~/.gitattributes
[merge "piie"]
    name = "piie merge"
    driver = piie_merge %A %P %O %B
    tool = piie
[mergetool "piie"]
    cmd = vim -O $MERGED ${MERGED}.rej

This into your ~/.gitattributes (including the star):

* merge=piie

Put this script into a directory which is listed inside your $PATH, name it piie_merge and make it executeable:


echo "vvvvvvvvvvv"
diff -up "$3" "$4" > "$2.patch"
patch "$2" < "$2.patch"
if (( $ret == 0 ))
    rm "$2.patch"
cp "$2" "$1"
echo "^^^^^^^^^^^"

exit $ret

Now you can do your usual git mergetool to resolve the conflicts using .rej files.