Normally, I use the following line in Git's pre-commit hook:
git diff --cached --check || exit 1
This makes a git commit
abort if there are any whitespace-related
errors. However, if you have code that already has whitespace issues,
you can simply pass an option to git rebase
to automatically correct
them:
git rebase --whitespace=fix reference
N.B.: Rebase just passes this argument to the git apply
command.