1

When viewing staged or unstaged changes via either git extensions or using the git diff commmand I can see that git thinks the whole file has changed. It displays a removal block for the whole file followed by an addition block (or vice versa) thus making it difficult to see exactly what has changed.

When I view the changes in a diff viewer such as winmerge, I can see the exact changes. Suspecting that it may be something to do with line-ending settings in git I decided to change the line ending settings in winmerge by checking the option 'Preserve origin EOL chars' thinking this would emulate the problem I'm seeing in git. However, this makes no difference. Somehow there are line-ending changes that git can see that the diff viewer cannot.

I get a related problem when I perform a git reset --hard. Git sill thinks some files have changed and displays them in the same way as described above but the diff viewer thinks nothing has changed. Annoyingly, performing a git reset --hard does not get rid of the files.

Any ideas?

=== Extra Note ====

It turns out that historically we had not configured the line endings in the repository which meant that the setting core.autocrlf used the default value of 'false' (see https://help.github.com/articles/dealing-with-line-endings/ for further explanation of this setting). A new .gitattributes file had been added with this configuration having a value of 'auto'. As a short term fix we commented out the setting of the text attribute so we reverted back our original settings. However, it's probably best if we adopt the recommended setting of 'auto' which requires a normalisation of the line endings.

1
  • You can specify how you want git diff to see changes. See git-scm.com/docs/git-diff Commented Sep 7, 2015 at 8:49

1 Answer 1

1

This is almost certainly caused by a line ending mismatch. You can use git diff -b to show the diff while ignoring whitespace changes, which should show you the substantive changes you're interested in.

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.