No whitespace in Git repositories
You can find whitespace with the help of Git with the following command: git diff-index --check --cached
.
You can have an automatic check for this by enabling a Git pre-commit hook ([your-project]/.git/hooks/pre-commit) with this code:
#!/bin/sh
if git rev-parse --verify HEAD >/dev/null 2>&1
then
against=HEAD
else
# Initial commit: diff against an empty tree object
against=4b825dc642cb6eb9a060e54bf8d69288fbee4904
fi
You can read more about this in my blog post Fight whitespace with Git
Written by Teddy Zetterlund
Related protips
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Best
#Whitespace
Authors
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#