Git diff -w ignore whitespace only at start & end of lines

ma11hew28 picture ma11hew28 · Dec 4, 2010 · Viewed 155.9k times · Source

I love to use git diff -w to ignore whitespace differences. But, I just noticed that it ignores even whitespace differences in the middle of lines. How could I only ignore whitespace differences that come at the start (^) or end ($) of lines?

Answer

Fake Code Monkey Rashid picture Fake Code Monkey Rashid · Dec 4, 2010

For end of line use:

git diff --ignore-space-at-eol

Instead of what are you using currently:

git diff -w (--ignore-all-space)

For start of line... you are out of luck if you want a built in solution.

However, if you don't mind getting your hands dirty there's a rather old patch floating out there somewhere that adds support for "--ignore-space-at-sol".