0

I'm using Bitbucket and I don't know if that is important.

Why is ^M being inserted after every line of my source code after merge conflicts. I'm not using Source Tree, just regular git through terminal.

yu_sha
  • 4,290
  • 22
  • 19
Alexander Kleinhans
  • 5,950
  • 10
  • 55
  • 111
  • ^M is the same as CR (Carriage return). On Windows, every line ends with CR+LF (unless you set up your editor differently). On Linux, CR has no special meaning and is displayed as ^M. This question is a possible duplicate of http://stackoverflow.com/questions/591923/make-git-automatically-remove-trailing-whitespace-before-committing You are getting -1 for swearing in the question. – yu_sha Aug 17 '15 at 22:19
  • 1
    possible duplicate of [git-diff to ignore ^M](http://stackoverflow.com/questions/1889559/git-diff-to-ignore-m) – Makoto Aug 17 '15 at 22:23
  • 1
    It blows my mind that we're *still* mucking about with CRLF. – msw Aug 18 '15 at 06:41

1 Answers1

1

Your text editor is showing this escape character if your file contains a mixture of unix and windows style line endings. This is most probably caused by how your text editor and git are set up.

Personally, I always ensure that I checkout from git using unix line endings (also on Windows) and submitting unix line endings, too. In the .gitattributes files you can e.g. specify:

* text eol=lf

Normally, good text editors respect the line ending they find and don't try to convert a file. But you might check the configuration of your text editor.

There is no automated solution for the file having a mixture of both kinds of line endings (^M). You have to go through the file and remove those characters.

Sebi
  • 8,323
  • 6
  • 48
  • 76