How can I get a side-by-side diff when I do "git diff"?

user783774 picture user783774 · Oct 6, 2011 · Viewed 100.2k times · Source

When I type "git diff", I'd like to see a side-by-side diff, like with "diff -y", or like to display the diff in an interactive diff tool like "kdiff3". How can this be done?

Answer

Matt Ball picture Matt Ball · Oct 6, 2011

Try git difftool

Use git difftool instead of git diff. You'll never go back.

UPDATE to add an example usage:

Here is a link to another stackoverflow that talks about git difftool: How do I view 'git diff' output with my preferred diff tool/ viewer?

For newer versions of git, the difftool command supports many external diff tools out-of-the-box. For example vimdiff is auto supported and can be opened from the command line by:

cd /path/to/git/repo
git difftool --tool=vimdiff

Other supported external diff tools are listed via git difftool --tool-help here is an example output:

'git difftool --tool=<tool>' may be set to one of the following:
        araxis
        kompare
        vimdiff
        vimdiff2

The following tools are valid, but not currently available:
        bc3
        codecompare
        deltawalker
        diffuse
        ecmerge
        emerge
        gvimdiff
        gvimdiff2
        kdiff3
        meld
        opendiff
        tkdiff
        xxdiff