git: How to show diffs of segments, not line oriented

f:id:ichikaway:20160622115131p:plain

 

On github, we can check diffs of segments. It's very convinient when an old line and a new line are very similar.

I want to adopt this function to git command on my local pc.The diff-highlight makes it and looks like the above screenshot.

 

diff-highlight is perl script and maintained in the git project.

https://github.com/git/git/tree/master/contrib/diff-highlight

 


At first, Download this script in /usr/local/bin, and give execute permission.

wget https://raw.githubusercontent.com/git/git/master/contrib/diff-highlight/diff-highlight

chmod 755 diff-highlight

 

You can try out the diff-highlight program with

git log -p --color | diff-highlight

 

I want to use it all the time, I write following configuration in .gitconfig file.

[pager]
  log = diff-highlight | less
  show = diff-highlight | less
  diff = diff-highlight | less