Search code examples
vimvimdiff

Git is not working with vimdiff


I am using meld with git for merging and I want to try vimdiff. Configured three way merge with git and then my own diff command:

[merge]
    tool = vimdiff3
    conflictstyle = diff3
[mergetool "vimdiff3"]
    cmd = gvim -f -d \"$LOCAL\" \"$BASE\" \"$REMOTE\" \"$MERGED\"

But everytime I try to run mergetool, git just quickly respond "[file] seems unchanged" and skips the merge.

On top of that, I'd like to get real three-way merge (four files) with merged window in the bottom, this shold work but I saw many reports it is not working on the internet:

    cmd = gvim -f -d -c \"wincmd J\" \"$MERGED\" \"$LOCAL\" \"$BASE\" \"$REMOTE\"

Solution

  • You could check if the upcomming mergetools/vimdiff3 setting (for git 2.0.x Q3 2014) would work for you.

    See commit 7c147b7 by Felipe Contreras (felipec), merged only recently in commit 3a9dae7 (June 2014):

    mergetools: add vimdiff3 mode

    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.

    gvimdiff3|vimdiff3)
      if $base_present
      then
        "$merge_tool_path" -f -d -c 'hid | hid | hid' \
          "$LOCAL" "$REMOTE" "$BASE" "$MERGED"
      else
        "$merge_tool_path" -f -d -c 'hid | hid' \
          "$LOCAL" "$REMOTE" "$MERGED"
      fi
    ;;
    

    The new file mergetools/vimdiff3 has been added, which means that all you would need to do is:

    git mergetool --tool=vimdiff3
    

    (without having to configure mergetool.vimdiff3.cmd)