Julius Plenz – Blog

Strip whitespace on rebase

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.

posted 2011-01-25 tagged git, hook and whitespace