Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

9
  • 43
    For those who find this now, it's worth noting that Checkout Windows-style, commit Unix-style line endings auto-sets core.autocrlf to true Commented Dec 23, 2014 at 21:25
  • 23
    Note that the line git config --global core.whitespace cr-at-eol would turn off other settings that are default. There are three defaults: blank-at-eol, blank-at-eof and space-before-tab. So to enable cr-at-eol while keeping the others you would need to use git config --global core.whitespace blank-at-eol,blank-at-eof,space-before-tab,cr-at-eol.
    – Zitrax
    Commented Sep 27, 2016 at 11:30
  • 3
    For my project (it was checkout out on Windows and I'm viewing it on Linux), cr-at-eol got rid of ^M at the end of lines in git diff all right, but GIT still showed those lines as different, although the line ending was the only difference. Commented Jul 25, 2017 at 12:19
  • 2
    @Zitrax's comment is false; the default value of core.whitespace is "". If you wanted to, say, enable cr-at-eol and disable blank-at-eol, you would need to set core.whitespace to "cr-at-eol -blank-at-eol". See also git help config. Commented Apr 24, 2018 at 22:59
  • 11
    I think git needs a bit more complexity, a few more conflicting settings for end of line. I think git should be more concerned about my whitespaces. For example throw an unrelated fatal error and leave the repository in a corrupt state when encountering Mac line endings on a Windows (but not Linux) machine. I mean why would I use a VCS that would mind it's business and let me use whichever line endings I want? I see they're trying, but they should throw in half a dozen more line-ending behaviors, to solve a problem that doesn't exist. They're almost there! Keep it up.
    – Rolf
    Commented Sep 3, 2018 at 10:10