0

I don't understand why but when someone commits new file it shows on my end as if I deleted everything and re-written exactly the same thing when I didn't even touch the file.

We both use Windows. Any idea what causes this and how to avoid it?

enter image description here

Stan
  • 25,744
  • 53
  • 164
  • 242
  • 2
    Only thing I can think of is line endings. I know you are both on the same platform, but do you perhaps have different settings for core.autocrlf ? – Doon Jul 22 '13 at 11:36
  • @Doon I had it set to `true` so I set it to `false` and reload GitHub application, still it shows me this. – Stan Jul 22 '13 at 11:51
  • too late at that point. since the conversion is done on checkout. So if your settings are different, when you checked the files out from the repo. it would have done the conversion. If you haven't changed anything in the file, just re checkout that version with the new setting and see if that changes anything? – Doon Jul 22 '13 at 11:57
  • http://stackoverflow.com/questions/2825428/why-should-i-use-core-autocrlf-true-in-git This might help as well. – Doon Jul 22 '13 at 11:58

1 Answers1

2

They're certainly not the same, or else git wouldn't have mentioned that they were different. So there is only one possibility if everything else looks the same: the stuff you can't see must be different, i.e. white space.

It's likely not a space/tab kind of issue based on your screen shot. So it's almost certainly either white space at the end of the line (like extra spaces) or the ever so much more likely cr/lf issue with using windows.

You need to carefully set core.eol, core.safecrlf and core.autocrlf. In particular, if you set core.safecrlf to true git will actually yell at you if you edited it incorrectly.

If you want to check what actually happened, you'll likely need to open in checkin via it's tag and check the line-endings using an editor that can display them, or you can simply check the size before and after. The crlf version of the file should be longer because of the extra CR. In fact, it should (based on your diff) be 108 bytes longer.

Wes Hardaker
  • 21,735
  • 2
  • 38
  • 69