Nick Vanderbilt
Nick Vanderbilt

Reputation: 38390

How to make git enable whitespace diff while doing git add

I ran following command on my project to remove trailing whitespaces.

find . -name '*.rb' | xargs perl -pi -e 's/ +$//'

It worked however when I do

git add -p

I see that one line has been deleted and the same line being added. I do not see any visual indicator that a trailing whitespace has been removed. I am not sure if it is relevant but I have following setting on my .gitconfig

[apply]
    whitespace = nowarn

While doing git add -p what extra parameter I should pass to see a visual indicator that a trailing whitespace has been deleted?

Upvotes: 2

Views: 361

Answers (1)

Infiltrator
Infiltrator

Reputation: 1681

You may be able to see it using a graphical tool, such as gvimdiff. Try using "git difftool".

And as far as I can tell, the default behaviour for git is to show trailing whitespace highlighted in red, only in lines you ADD, not those being taken away.

Upvotes: 1

Related Questions