Search code examples
git

How can I check for whitespace/tab errors in my git commit?


Is there any way I can check for whitespace/tab (i.e. don't use tab, use spaces instead, and do have end of line space) in my git commits?

I have ~ 10 commits, I want to double check them before I push.

What Git mechanism should apply for this case?


Solution

  • The right way to "double check" is through a pre-commit hook to detect whitespace errors.
    (You will find hook examples there)

    Trying to do that just before a push is a bit late, even though git1.8.2 has now a pre-push hook.

    You can still:

    • put a pre-commit hook in place
    • do a rebase -i HEAD~10 (replaying all your 10 commits), which will trigger that pre-commit hook.