Today I Learned

hashrocket A Hashrocket project

Remove whitespace changes, then `git add -p`

git diff -w --no-color | git apply --cached --ignore-whitespace && git checkout -- . && git reset && git add -p

git diff -w --no-color creates a diff

git apply --cached --ignore-whitespace applies the diff ignoring whitepace, and indexes it

git checkout — . removes the unindexed “whitespace" changes

git reset resets the index to just he non-whitespace cahnges

git add -p adds the non-whitespace changes in patch mode

We did this with it alias gwap=“git diff -w --no-color | git apply --cached --ignore-whitespace && git checkout -- . && git reset && git add -p"

See More #git TILs