Adam Luchjenbroers
Adam Luchjenbroers

Reputation: 5029

Git - Weirdness when using .gitattributes to force consistent line endings

So, I've recently added a .gitattributes file to one of our repositories to try to force consistent line endings:

  # All Perl Sources should use Unix style line endings
  *.pl text eol=lf
  *.pm text eol=lf

But both myself and a lot of other developers are encountering a lot of "phantom changes" where git seems to detect the file as "changed" even though there's no change. Every line shows up as added, then deleted.

I suspect it's getting confused about line endings (and thus detecting each line as changed), but what's weird here is:

Has anyone encountered this before, and is there a way to avoid or resolve this issue?

Upvotes: 3

Views: 242

Answers (1)

VonC
VonC

Reputation: 1329712

With Git 2.16 or more, do at least once:

git add --renormalize .
git commit -m "normalize eol files"
git push

Then try and clone your repo elsewhere, and check that git status behaves as expected.

Make sure you don't have core.autocrlf set to true.

git config core.autocrlf

And you can test for your files eol style.

Upvotes: 2

Related Questions