Launch diff tool from Git GUI

Scorb picture Scorb · Aug 10, 2017 · Viewed 9.6k times · Source

I am exploring using the Git GUI software the is default bundled with git.

From the unstaged changes window, I would like to select a file and then launch it in an external side by side diff tool like kdiff.

I can not figure out how to do this. Is it possible to do this?

Thanks

Answer

Sasha Bond picture Sasha Bond · Apr 2, 2018

You can achieve this with the following (I am using Windows, for MAC should be something similar):

  1. configure your git to use diff tool, kdiff3 for example, if you set it up correctly, then after you open CMD and cd to your git folder and run git difftool -y "path to your changed file" KDiff3 will pop the comparison window. If that works, continue
  2. Now you can add custom tool to Git Gui with the name diff file and command git difftool -y "$FILENAME" or you can edit directly your global git config file

%userprofile%.gitconfig

and add in the end

[guitool "diff file"]
    cmd = git difftool -y \"$FILENAME\"
    noconsole = yes
    needsfile = yes

after that in your Git Gui you will see under Tools menu diff file and when you click on it KDiff3 (that would be default difftool for git) will pop with the file differences

Using the same approach you can edit selected item from Git Gui - for this add in global config section

[guitool "file Edit"]
    cmd = \"C:\\Program Files (x86)\\Notepad++\\notepad++.exe\" \"$FILENAME\"
    noconsole = yes
    needsfile = yes