Search code examples
gitgithubdiffbeamer

Why are line endings all showing diffs on github?


I was editing a colleagues beamer presentation, and when I pushed my changes, I found these end-of-line diffs all over the place.

enter image description here

We're both on macs and I can't figure out where they're coming from or, more importantly, how to make them go away. (I edit using latextools in Atom, if that matters)


Solution

  • The hint is in the darker red elements of the diff, which highlight the characters that have changed. Note that it's not just a uniform width at the end of the line, there are a variable number of characters highlighted, but they're all whitespace.

    What has probably happened is that during editing, your colleague has left various insignificant whitespace at the end of lines - spaces where sentences have been edited, tabs where formatting has been adjusted, etc. Their editor was probably not configured to display this whitespace, so they didn't notice.

    Your editor, however, was configured to automatically trim off such whitespace - quite a common feature - so as soon as you touched the file and saved it, the ends were all tidied up.

    Either you can turn the feature off, your colleague can turn it on, or you could just ignore the whitespace in the diff view by adding ?w=1 to the URL (unfortunately, this disables commenting, as it messes with the line numbers sometimes).