Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What's the difference between vimdiff and vimdiff2 in git?

Tags:

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

git mergetool 

offers me both.

like image 448
nomadStack Avatar asked Jan 12 '15 12:01

nomadStack


People also ask

How do I use Vimdiff as Mergetool?

In Vim, open a file with conflict markers, and start mergetool. vim-mergetool would show 2-way diff in a new tab with $MERGED file on the left. By default, all conflicts are already resolved by picking up ours/LOCAL version. You don't need to edit raw conflict markers manually.

How do you resolve conflicts in Vimdiff?

Resolving merge conflict with vimdiff Save the file and quit (a fast way to write and quit multiple files is :wqa ). Run git commit and you are all set!


1 Answers

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.

like image 65
VonC Avatar answered Oct 06 '22 19:10

VonC