March 7, 2013

Configure git to use a different tool for diffing

I don't like default git diff output: I prefer vimdiff or tkdiff. Here is a recipe that explains how to set up external diff.
Your basic ~/.gitconfig should have [diff] section as in:
        name = <your name>
        email = <your@email>
        status = auto
        diff = auto
        branch = auto
        interactive = auto
        editor = vim
        pager = less -FRSX
        external = /home/<username>/bin/
        tool = vimdiff
Create external and make it executable (chmod +x):

/usr/bin/tkdiff "$2" "$5" | cat
For vimdiff use:

/usr/bin/vimdiff "$2" "$5" | cat

[Update - 08/10/2014]

Newer git can do this for you:
git config --global diff.tool tkdiff
git config --global merge.tool tkdiff
git config --global --add difftool.prompt false

No comments:

Post a Comment