Created
September 5, 2017 11:57
-
-
Save atfornes/f4a917c6c0cf5b773824a6545ae2ef5e to your computer and use it in GitHub Desktop.
Git rebase interactive cleaning space only line changes
This file contains 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
#!/bin/bash | |
## Rebases interactive current branch over master (or <branch> provided as first argument) removing whitespace changes | |
# based on https://stackoverflow.com/a/9784089/4928558 and https://stackoverflow.com/a/23911001/4928558 | |
branch=master | |
if [[ $1 ]]; | |
then | |
branch=$1; | |
fi | |
git rebase -i -Xignore-all-space $branch -x "git diff --binary HEAD^ -U0 -w --no-color > patch && git checkout HEAD^ -- . && git apply patch --ignore-whitespace --unidiff-zero && git add -u && git commit --amend --no-edit" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment