A colleague of mine at work has set up his IDE to clean up all trailing whitespace on save. Nothing wrong with that, except that he is the only one, which very often means in practice that his commits are sprinkled with fixes of other people's whitespace mixups. Because of these unrelated line changes, you easily get in conflict situations when cherry-picking or merging.
Here is a trick I use to cherry-pick this kind of commits, without the whitespace parts.
For example, say his commit SHA1 is "abc123".
First get the commit's "patch" without whitespace changes (option -w
) and apply it (with option -p1
to munge the git specific diff file path prefixes):
git show -w abc123 | patch -p1
Make sure everything is fine and commit with the original commit metadata (option --reuse-message
or just -C
in short):
git commit -a -C abc123