Skip to content

Instantly share code, notes, and snippets.

@jasonm23
Last active October 13, 2017 07:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jasonm23/7c0c064d6c1618f5ad5208d543ca1e1a to your computer and use it in GitHub Desktop.
Save jasonm23/7c0c064d6c1618f5ad5208d543ca1e1a to your computer and use it in GitHub Desktop.
Scrub trailing whitespace from your changed files under git
#!/bin/sh
git status -s | cut -c3- | while read filename
do
sed -ibak 's/ *$//' "$filename"
done
echo "trailing whitespace cleaned"
git clean -fd **/*bak
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment