Search code examples
gitdiffconfigvimdiffmeld

Why does git difftool use git diff instead?


I want git diff to be a quick command line solution to see the difference between two files, and then I want git difftool to launch meld for a more graphical view of the file differences.

Currently, git diff does exactly what I want it to, however when I run git difftool script.js, git tries to launch vimdiff instead of meld:

Viewing (1/1): 'script.js'
Launch 'vimdiff' [Y/n]:

If I specify the tool with git difftool -t meld script.js it tries to launch meld as it should:

Viewing (1/1): 'script.js'
Launch 'meld' [Y/n]:

How do I get git difftool <filename> to launch meld while git diff <filename> still uses vimdiff?


My .gitconfig contains the following:

[diff]
     tool = vimdiff
[difftool]
    tool = meld
[difftool "meld"]
    path = C:\\Program Files (x86)\\Meld\\Meld.exe

Solution

  • git config --global diff.tool meld
    

    This will set the default difftool to meld. I.e. when you invoke git difftool without the --tool parameter, git will run meld.

    You can also remove that part of your config, git won't read difftool.tool as it's not one of git's known config options:

    [difftool]
        tool = meld