Last active
August 29, 2015 14:23
-
-
Save seaders/bfae8312061df071114f to your computer and use it in GitHub Desktop.
If you've a big dirty git workspace, with loads of documents with whitespace (which you know you can safely commit), you can use python's sh library (https://github.com/amoffat/sh) and the script below to safely stage all files with only whitespace changes
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/python | |
| import sh | |
| git = sh.git.bake('--no-pager', # @UndefinedVariable | |
| _cwd='/Developer/repos/git/example') | |
| for fname in git.diff('--name-only', '--full-index', 'HEAD').splitlines(): | |
| if '' == git.diff('-w', fname): | |
| print 'adding', fname | |
| git.add(fname) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment