Skip to content

Instantly share code, notes, and snippets.

@davidlee
Created February 2, 2010 00:27
Show Gist options
  • Save davidlee/292218 to your computer and use it in GitHub Desktop.
Save davidlee/292218 to your computer and use it in GitHub Desktop.
# strip whitespace before commit
for i in $(git diff-index --cached --name-only HEAD); do
EXISTS=$(git diff-files --name-only | grep $i);
if [ "$EXISTS" != "" ]; then
echo unstaged dirty changes for $i, not touching
else
perl -pe 's/[\t ]+$//g' -i $i;
git-add $i;
fi
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment