20

What's the difference between them? My search engine results talk only about vimdiff, yet the command

git mergetool 

offers me both.

1 Answer 1

20

vimdiff2 was introduced in commit 0008669 (Sept 2010, for git 1.7.4)

It is like vimdiff, but with different merge options (as commented in commit b2a6b71, git 1.8.2: "vimdiff and vimdiff2 differ only by their merge command").

It (vimdiff2) forces a 2-way merge, versus vimdiff which will use a 3-way merge if the base (common ancestor) is detected:

gvimdiff|vimdiff)
    if $base_present
    then
        "$merge_tool_path" -f -d -c 'wincmd J' \
            "$MERGED" "$LOCAL" "$BASE" "$REMOTE"
    else
        "$merge_tool_path" -f -d -c 'wincmd l' \
            "$LOCAL" "$MERGED" "$REMOTE"
    fi
    ;;
gvimdiff2|vimdiff2)
    "$merge_tool_path" -f -d -c 'wincmd l' \
        "$LOCAL" "$MERGED" "$REMOTE"
    ;;

Note that commit 7c147b7 (April 2014, for Git 2.1.0 August 2014) actually introduces vimdiff3 as well:

It's similar to the default, except that the other windows are hidden.
This ensures that removed/added colors are still visible on the main merge window, but the other windows not visible.

Specially useful with merge.conflictstyle=diff3.

2
  • What would you recommend for resolving merge conflicts? "Unfortunately Vim struggles a bit with three-way diffs, both with highlighting the differences and with shuffling individual changes between the three windows." Source: vim.wikia.com/wiki/A_better_Vimdiff_Git_mergetool
    – nomadStack
    Jan 13, 2015 at 13:40
  • @nomadStack indeed. I prefer to use kdiff3.
    – VonC
    Jan 13, 2015 at 13:56

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.