0

I'm trying to do a simple thing:

git cherry-pick --no-commit <commit with a lot of useless whitespace changes> -Xignore-all-space

Perhaps I'm overlooking something obvious but I can't force git into ignoring any whitespace change from the given commit (mainly trimmed trailing spaces). My understanding is that it is because "-Xignore-all-space" works only for conflict resolution, not like a merge option.

So what works then? I can't be the first person with this issue. git is 2.35.1.

Miro Kropacek
  • 2,742
  • 4
  • 26
  • 41
  • 1
    The `-X` options in cherry picking *are* the `-X` options in merging; merging and cherry-picking share the merge engine in Git. But yes, these `-X` options are only for the conflicting parts. You'll need to clean up unwanted whitespace changes manually, either before (perhaps by cherry-picking once and cleaning up after and committing so that you have a "clean" commit to cherry-pick) or after doing the cherry-pick (perhaps with `--no-commit` as you're doing). – torek Feb 19 '22 at 09:37
  • My situation is reversed; I have a source code full of bad whitespaces and I want to avoid useless commits with whitespace changes (it's an old branch, the least amount of changes in commits has the top priority here). So far my only solution was to clone *yet another* tree and manually run "diff -ruw old_tree new_tree > changes.patch" and apply that manually. I would expect git to be a bit more helpful here... – Miro Kropacek Feb 19 '22 at 12:14

0 Answers0