git diff

By default git usually launches vimdiff for diffs and merges, but I would rather prefer kdiff3 gui for merges/diffs. Here are some of my notes about how to set it up.

For a detailed list of options that git diff supports visit this link

git supports various tools for merge and diff, here is a partial list: - kdiff3 & documentation - tkdiff - meld - vimdiff - gvimdiff

You can setup kdiff3 by default as diff tool by executing follow command:

git config --global diff.tool kdiff3

for other tools see here: Viewing all git diffs with vimdiff

Following commands setup the kdiff3 as the global default diff and merge tool. (reference

git config --global --add merge.tool kdiff3
git config --global --add mergetool.kdiff3.path "C:\\inpath\\kdiff3.exe"
git config --global --add mergetool.kdiff3.trustExitCode false

git config --global --add diff.guitool kdiff3
git config --global --add difftool.kdiff3.path "C:\\inpath\\kdiff3.exe"
git config --global --add difftool.kdiff3.trustExitCode false

Alternatively one can modify the config file in repository to use specific tools for a certain repository (reference:

    tool = kdiff3
[mergetool "kdiff3"]
    path = C:\\inpath\\kdiff3.exe
    trustExitCode = false
    guitool = kdiff3
[difftool "kdiff3"]
    path = C:\\inpath\\kdiff3.exe
    trustExitCode = false

One of the things i found a bit annoying was that git always prompts to launch difftool, default behavior. (reference

git config --global difftool.prompt false

or tweak the config file for repo:

  prompt = false

One the things I wanted to do was to diff a file between commits, following command achieves the same effect (reference

git difftool HEAD~3 HEAD~2 path/to/file
git difftool HEAD~2 HEAD~1 path/to/file
git difftool HEAD~1 HEAD path/to/file