steve_gallagher
steve_gallagher

Reputation: 3898

Git: A ton of blank lines showing up in diff when I haven't modified them

Extremely frustrated. I have diffs that look like this (going on and on for nearly the whole file, in nearly every file I edit):file diff

even though I only modified one line. I have tried adjusting various core git config settings like autocrlf, whitespace, and safecrlf. I tried adding a git/info/attributes file that contains * -crlf to try to ignore any line ending differences, in case that's the cause.

I seem to be the only one in my office having this issue despite having identical config settings. I'm using Vim, but I can't see that it would be causing this issue, but I'm the only one using it so that's the consensus, and I can't explain it.

Is there a way to eliminate these kinds of whitespace differences?

Upvotes: 3

Views: 387

Answers (3)

mMontu
mMontu

Reputation: 9273

You may be changing the file format when you edit the file, thus converting the line terminations, for example from CR to CR+LF or EOL.

You can check the file format before and after editing the file with :set ff.


The change on whitespace that you noticed with the aid of ldav1s can be seem on Vim with the 'list' option:

:set list

Upvotes: 2

Josh Lee
Josh Lee

Reputation: 177584

git diff -w ignores whitespace changes. You can also try --word-diff, which behaves differently but also ignores whitespace.

Upvotes: 2

ldav1s
ldav1s

Reputation: 16305

I'm not a Vim guy, but I know a few things about it, like it's very customizable, and has options for line endings, etc. Since these get introduced by just altering one line of code, it seems to me that Vim might be "fixing" the lines you didn't knowingly alter, and git is just displaying the result of that.

Upvotes: 3

Related Questions