What are these ^M's that keep showing up in my files in emacs?

Neil Sarkar picture Neil Sarkar · Nov 30, 2009 · Viewed 99.8k times · Source

So I think it may have to do with textmate, but we work in a small team and are having some issues with full-file conflicts of nearly identical files in git because each line of one branch has a ^M appended to it.

What is this mysterious ^M character supposed to do, and where could it be coming from?

Our developers use emacs on Windows/Mac, TextMate on Mac, coda on Mac, and occasionally the wp-admin text editor.

Anybody ever have this issue stemming from one of those?

Answer

Josh Lee picture Josh Lee · Nov 30, 2009

In git-config, set core.autocrlf to true to make git automatically convert line endings correctly for your platform, e.g. run this command for a global setting:

git config --global core.autocrlf true