Git add everything but whitespace changes

I was fixing some spelling errors in an open source repo in GitHub, but for some reason, when I went to git diff to see which changes would be staged, I started seeing hundreds of whitespace edits I could've sworn I didn't intend to make. I tried to use git add -p to tell git which whitespace edits to ignore, but it just wasn't feasible to parse through so many false hits!

So a quick Gogle search led to this Stack Overflow answer which suggests: 
 git diff -w | git apply --cached --ignore-whitespace

After this command: 
 1. git diff --cached shows the changes that have been be staged for commit (which is the stuff you want) 
 2. git diff shows all the whitespace changes that wasn't staged for commit (which is exactly what you wanna toss away)

Hooray!

Like what you read? Give Robin Kim a round of applause.

From a quick cheer to a standing ovation, clap to show how much you enjoyed this story.