How to ignore files from 'git status' if only white spaces and line breaks changed

I could not find a native git solution for identifying what really changed using git status but the following one-liner works well under linux:

for m in $(git status | grep modified| awk '{print $2}');do test -z "$(git diff -w $m)" || echo $m;done

The result will be a list of modified files excluding files with only whitespace changes.

This is especially useful before writing commit messages when you want to see only the files with real edits which is often a problem when moving back and forth between windows and linux systems. If you have control of both systems then configuring whitespace settings in git may be a cleaner solution.


This should do the trick:

git diff -w | git apply --cached --ignore-whitespace

Patch would be applied with add without white space changes.

Tags:

Git