1

I submitted a commit with some fixes here and there, but github is not correctly showing the differences (e.g this line removed, this one added, etc). It just shows two big walls of code, one red (removed code) and one green (added code).

This is not the first time it happen to me, and this last time I was extra careful to not mess with any other parts of my code. I must be doing something wrong, every free online tool I have tried shows the text differences easily.

How can I prevent this from happening again?

Note: in case it matters, I am using Windows and submitting them via their downloadable thingy.

ajax333221
  • 11,436
  • 16
  • 61
  • 95

1 Answers1

4

This looks like the standard Git on Windows line ending related issue ;-)

Running the following command in the bash command line interface should fix your problem.

$ git config --global core.autocrlf true

See this GitHub help page for more information about this subject.

nulltoken
  • 64,429
  • 20
  • 138
  • 130
  • 1
    Good answer. Probably also worth pointing to http://stackoverflow.com/a/10855862/43452 which has a more detailed answer. – Stobor Jan 15 '13 at 02:03
  • mmm I accepted too quick, after uploading [my .gitattributes](https://github.com/ajax333221/Isepic-Chess/blob/master/.gitattributes), my [last commit](https://github.com/ajax333221/Isepic-Chess/commit/f6bf187d0188df6ad16d2ce815523f6aaa0c98ad) still didn't show the differences correctly, maybe `* text=auto` wasn't enough?, who knows – ajax333221 Jan 15 '13 at 20:10
  • The git built-in line endings filtering mechanism only works with LF and CRLF line endings. Strangely, your last commit uses pre-OSX Macintosh CR line endings. – nulltoken Jan 15 '13 at 20:41