Last active
May 4, 2017 19:29
-
-
Save altphi/00463687f86e8bf7f1a80de7570ec3c7 to your computer and use it in GitHub Desktop.
Clear all whitespace-only-changes from files in a git repository.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env sh | |
# leaves a backup of all changes in git stash, creates a patch ignoring whitespace changes, clears changes, applies patch | |
cd "$(git rev-parse --show-toplevel)" | |
git stash && git stash apply && git diff -w > changes.patch && git checkout . && git apply --whitespace=fix changes.patch && rm changes.patch |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment