git: showing within-line changes … within a line!

Just found this while looking for a way to show changes within a line rather than on separate +/- lines.  “git diff –word-diff” does the trick!  Thanks to A few git tips you didn’t know about by .

For an extra-clean diff, the final command I used was:

git diff --word-diff --ignore-space-at-eol --patience -b -w --ignore-blank-lines <file1> <file2>

My git installation (version 2.8.3 on cygwin) defaults to a color diff, which makes it extra-easy to read.

Edit: to use this on local files rather than files in your git repo, you can add the “–no-index” option:

git diff --word-diff --ignore-space-at-eol --patience -b -w --ignore-blank-lines --no-index <file1> <file2>

I added an alias called “fsdiff” for this and now can say “git fsdiff <file1> <file2>” for a very nice diff!

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s