The following alias lets you remove any whitespace from files that have been added to your index (staged):
wsf = !git commit -mTemp && git stash && git rebase HEAD~ --whitespace=fix && git reset --soft HEAD~ && git stash pop
To explain what is going on here:
- Commit your currently staged files
- Stash any uncommitted changes
- Rebase your last commit (from step 1) and remove any whitespace changes.
- Reset back to your previous commit, but keep changes in the index.
- Pop your previously uncommitted changes back off the stash.
Just don't put whitespaces in your code :D