nl-bdg
Last Updated: April 01, 2016
·
6.93K
· cam8001
B295f0081d0b36b1329a7ec86f23f870

More readable git word diff on OSX

When I make small changes to long lines, the standard git diff display can be a little hard to read.

A community script that improves this view was merged into the git trunk and released with git 1.7.10.

This tip has some brew specific path prefixing - but as long as you specify the path to diff-highlight it will work on any OS.

Before:

Picture

After:

Picture

Add this to your Git config:

# ~/.gitconfig
[core]
   pager = `brew --prefix git`/share/git-core/contrib/diff-highlight/diff-highlight | less
Say Thanks
Respond

8 Responses
Add your response

10579
10464074 938292239583056 7575720943166745998 n

You can use $(brew --prefix git)/share/git-core/contrib/diff-highlight

over 1 year ago ·
10580
B295f0081d0b36b1329a7ec86f23f870

Thanks! Updated.

over 1 year ago ·
10595
3c61d196e6fa8d34ec325ea5b22f5d91

I prefer just setting it in the global config without modifying $PATH. It's already a mess.
And it's all CLI.

git config --global pager.log `brew --prefix`/share/git-core/contrib/diff-highlight/diff-highlight
git config --global pager.show `brew --prefix`/share/git-core/contrib/diff-highlight/diff-highlight
git config --global pager.diff `brew --prefix`/share/git-core/contrib/diff-highlight/diff-highlight
over 1 year ago ·
10628
Me japan

Another solution which is more clean:

# ~/.gitconfig
[core]
    pager = `brew --prefix`/share/git-core/contrib/diff-highlight/diff-highlight | less
over 1 year ago ·
10647
B295f0081d0b36b1329a7ec86f23f870

Much cleaner, thanks! Updated.

over 1 year ago ·
10722
9b029fbe569b3af35c235aedb2420b7b

For those who had the same issues when installing this on Git 1.8.3.4 ( installed directly as Github suggest), here is what I had to follow besides this.

cd /usr/local/git/contrib
curl -O https://raw.github.com/git/git/master/contrib/diff-highlight/diff-highlight

And also to add this to my .gitconfig

[core]
  pager = /usr/local/git/contrib/diff-highlight | less
over 1 year ago ·
10950
Invisible me

Suite! Thanks!

over 1 year ago ·
18949
43f72359c88d186c64fa3e25b4996a7c

make sure "brew --prefix git" does not appear in ~/.gitconfig, or ruby will be fired up every time you call git diff

with brew --prefix git in ~/.gitconfig

$   time git diff
git diff  0.20s user 0.07s system 94% cpu 0.285 total

with absolute path in ~/.gitconfig

$ time git diff
git diff  0.05s user 0.04s system 92% cpu 0.095 total
over 1 year ago ·
Filed Under