Git unsteady lines where the only changes are spaces?

I have a source code file, which for some reason turned out to be mixed indentation (spaces and tabs used for indentation).

I made a few changes, and now I want to commit these changes to git. Unfortunately, I accidentally instructed my editor to correct all the indents. So now it looks like I modified a lot of lines where the only change is the change in white space.

My assignment should be considered by my colleagues at Gerrit , so the presence of a large number of lines with a changing space appears because the changes add a lot of noise.

How can I turn off all lines in a file where the only change is white space (or indentation), so that my git commit contains only the changed lines?

(Or, alternatively, how can I process only the lines of a file where more than white space changes?)

+6
source share
1 answer
git diff -w --no-color [file names] | git apply --cached --ignore-whitespace 

Basically, a patch is applied, which will be applied with the addition without changing the spaces. You will notice that after that there will still be unspecified changes, remaining spaces to check if they start: git checkout .

+7
source

Source: https://habr.com/ru/post/969956/


All Articles