3

I'm launch VSCode from an Ubuntu commandline on my Windows machine. I noticed that it was changing the line endings from the default Windows line ending. Specifically, when I was doing git diffs, I would see stuff like this:

enter image description here

Notice the ^M

So I read an article about how to fix this and it suggested the following git config change:

 git config --global core.autocrlf true

But I'm still seeing these line endings being used when I update my code.

wjandrea
  • 28,235
  • 9
  • 60
  • 81
dot
  • 14,928
  • 41
  • 110
  • 218
  • I think you need to tell your vscode to use a consistent EOL : see https://dev.to/wagslane/how-to-get-consistent-line-breaks-in-vs-code-lf-vs-crlf-2c3p – Ajeet Shah Dec 31 '21 at 18:00
  • 1
    You should never (well, hardly ever) use `core.autocrlf`. Use `.gitattributes` files instead. (That's only part of the problem, the other part is VSCode itself.) – torek Dec 31 '21 at 18:13

1 Answers1

0

The only thing you would read from me is: "What is the correct core.autocrlf setting I should use?"

Meaning:

git config --global core.autocrlf false

Then, as mentioned in "Disable git EOL Conversions":

git add --renormalize .

Using .gitattributes core.eol directive is the right approach to fix eol.
And you can check what is applied to which file with:

git ls-files --eol
VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250