git diff on a mac using tkdiff
Posted by ark, ,
I’m just getting used to git at my new job. I’m liking it a lot. One thing I miss is the side by side diffs we used to get with our code review tool and even tkdiff before that.
Here’s how I got it working on my machine:

brew install tkdiff
git config --global diff.tool tkdiff
git config --global difftool.prompt false

and I needed to add this to my .bashrc to get the Git.pm module available:

if [ -r /usr/local/lib/perl5/site_perl ]; then
  export PERLLIB=/usr/local/lib/perl5/site_perl:$PERLLIB
fi

next up, I did start using Kaleidoscope. I like it a lot. but then I saw rubymine's diffs and I got a bit jealous.

NOTE: this is super helpful to stop those .orig files lying around

git config --global mergetool.keepBackup false

-------------------------------------------------------------------------------

If for some reason you're using super old git then these instructions might work.
brew install tkdiff
git config --global diff.external ~/bin/share/git-diff-wrapper.sh
git config --global --replace-all core.pager "less -F -X"

~/bin/share/git-diff-wrapper.sh is this file:
#!/bin/bash
# http://stackoverflow.com/questions/255202/

# diff is called by git with 7 parameters:
# path old-file old-hex old-mode new-file new-hex new-mode

DIFF_PROG=$(which tkdiff)

if [ ! -x "$DIFF_PROG" ]; then
DIFF_PROG=$(which diff)
if [ ! -x "$DIFF_PROG" ]; then
DIFF_PROG=/usr/bin/diff
fi
fi

"$DIFF_PROG" "$2" "$5"

The most common thing I want to do is see how much my current branch’s file differs from the master branch:
git diff origin/master -- app.coffee
git difftool is the new way I've been doing that.

also to revert a single file do this...

git checkout -- app.coffee

Comments