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.

6
  • 1
    I had this problem in a repo where some of the files had \r\n line endings and some had \n line endings (I don't know if that's relevant); diffs of the former showed the ^M in the modified lines (that is, the + lines). core.autocrlf was set to true. Running git config core.pager "tr -d '\r' | less -REX" got rid of the pesky ^Ms. Thanks!
    – labreuer
    Commented Feb 1, 2018 at 17:39
  • 6
    Thanks for this. This is the only answer if you must work with differing line endings in your repo(s) -- e.g. you use checkout as-is, commit as-is, purposefully.
    – Mike
    Commented Mar 14, 2018 at 1:55
  • git diff -b is what I was looking for, but I do appreciate the thorough explanation. Commented Sep 24, 2018 at 9:09
  • 1
    Yes! Of all the answers to this question, modifying the git "config" file's [core] section by adding pager = tr -d '\\r' | less -REX was the only answer that worked for me. Thank you!
    – Hoonerbean
    Commented Feb 6, 2020 at 22:06
  • git diff -b did not work, but the config modification did.
    – Hoshi
    Commented Apr 1, 2020 at 20:08