When I run git difftool --tool-help or git mergetool --tool-help, I see:
vimdiffvimdiff1vimdiff2vimdiff3
What are these different "versions"? I assume they all start Vim with different options, but what are the options? Are they documented anywhere?
They don't seem to be documented anywhere, unfortunately.
The relevant source code is here. Note how
vimdiff,nvimdiff, andgvimdiffare all implemented with the same script.Difftool
When invoked as a difftool, they all do the same thing:
This starts Vim in read-only mode
-Rand diff mode-d. For information on diff mode, see the manpagevimdiff(1)and the Vim help pagediff.txt.Mergetool
When invoked as a mergetool, the behavior of these options varies.
In the diagrams below,
Localcorresponds to "ours",Remotecorresponds to "theirs",Basecorresponds to "merge base", andMergeis the file that will actually be saved to the work tree (and staged to the index if the resolution is successful).vimdiffIf there is a "merge base" present, the window layout is:
If there is not a merge base present, the layout is:
vimdiff1The layout is:
Localwill then be saved to the work tree upon success, taking the place ofMerged.vimdiff2The layout is identical to
vimdiffwithout a merge base.vimdiff3Each of
Local,Remote,Base(if present) will be opened but hidden.Mergedwill be opened and visible. You can switch among these buffers with the:buffercommand.Create your own mergetool!
Let's create a
vimdiff4, which uses the same layout asvimdiff-with-Base, but omitting the Base part.Add the following to your Git config (e.g.
$XDG_CONFIG_HOME/git/config):When you invoke
git mergetool --tool-help, you will see a new line in the output:Now you can run
git mergetool --tool=nvimdiff4, which will invoke the command we specified above.