4

I used to get warnings about LF will be replaced by CRLF when doing a git commit.

I played around with autocrlf but setting it to true or false both caused problems. In the end, after this comment (LF will be replaced by CRLF in git - What is that and is it important?) by @Drew Noakes, I just unset it and that fixed the warnings.

However, now, when I run git diff I get output like this:

-       original line;
+       new line;^M

What's going on and is there any way of getting rid of these pesky ^Ms once and for all?

If it helps, this is my own repo (i.e. I have complete control over the code base) and I'm on a Mac.

Community
  • 1
  • 1
Snowcrash
  • 80,579
  • 89
  • 266
  • 376
  • Do you have `.gitattributes` files with `core.eol` directive in it? – VonC Feb 20 '15 at 09:20
  • @VonC I don't but I do have a .gitattributes file with `*.pbxproj -crlf -diff -merge` in it. I assume that's got nothing to do with the problem as it's only applying this to pbxproj files. – Snowcrash Feb 20 '15 at 09:24

2 Answers2

1

Try running dos2unix or a similar program on the tex file.

NorrisNose
  • 11
  • 3
0

To remove them, you can execute something like this from your shell:

$ find -type f -exec sed -i -e 's/^M//g' {} +

... where you need to insert ^M using [Ctrl+V] [Ctrl+M] (see here for more options remove ^M characters from file using sed). Since you're on a Mac, they shouldn't come back after that, but I admit I'm not entirely sure about git not putting them back.

Community
  • 1
  • 1
Ludo
  • 813
  • 1
  • 9
  • 21