Skip to content

Instantly share code, notes, and snippets.

@wezm
Created August 27, 2011 09:25
Show Gist options
  • Save wezm/1175182 to your computer and use it in GitHub Desktop.
Save wezm/1175182 to your computer and use it in GitHub Desktop.
Strip trailing whitespace in modified files tracked by git
#!/bin/sh
git ls-files --modified '*.[hm]' | xargs sed -i '.bak' 's/[[:space:]]*$//'
@wezm
Copy link
Author

wezm commented Jul 29, 2012

I started getting this problem too. It happens when the files aren't in the top level of the project. I've come up with a shorter, better script as a result. Gist, updated.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment