Back

Explore Courses Blog Tutorials Interview Questions
0 votes
2 views
in DevOps and Agile by (19.4k points)

I have my text editor to automatically trim trailing whitespace upon saving a file, and I am contributing to an open-source project that has severe problems with trailing whitespace.

Every time I try to submit a patch I must first ignore all whitespace-only changes by hand, to choose only the relevant information. Not only that but when I run git rebase I usually run into several problems because of them.

As such I would like to be able to add to index only non-whitespace changes, in a way similar that git add -p does, but without having to pick all the changes myself.

Does anyone know how to do this?

EDIT: I cannot change the way the project works, and they have decided, after discussing it on the mailing list, to ignore this.

1 Answer

0 votes
by (27.5k points)

The options -U0, and --unidiff-zero respectively to workaround context matching issues, and here you can ignore the --no-color but if you have colors set to always, then you have to use it: 

$ git diff -U0 -w --no-color | git apply --cached --ignore-whitespace --unidiff-zero -

Related questions

Browse Categories

...