0

I have a Git repository on Github using LF as line-endings.

When I'm on Windows, I can't, for the life of me, to make existing files to show using LF endings.

What I have tried so far:

  • I ran this globally git config --global core.autocrlf false
  • I cloned my repo again.
  • I tried normalising my repo with git add --renormalize .
  • My repository has a .gitattributes file with * text=auto.
  • On WebStorm, I set Editor -> Code Style -> Line separator: Unix and macOS (\n) <- Apparently this only affects new files.

Now, if I open any existing file on WebStorm or VSCode, the file still shows as CRLF. As in the Screenshot.

How can I make it, so that, when I open an existing file, it will show as LF?

enter image description here

enter image description here

Andre Pena
  • 56,650
  • 48
  • 196
  • 243

1 Answers1

0

It worked for me after I executed this ritual How do I force Git to use LF instead of CR+LF under Windows?. I have no idea what I'm doing:

  • git config core.eol lf <-- I'm not sure if this one is necessary or even right.
  • git rm --cached -rf .
  • git diff --cached --name-only -z | xargs -n 50 -0 git add -f
  • git ls-files -z | xargs -0 rm
  • git checkout .

The only "problem" is that, on VSCode, new files are still in CRLF (disgrace). So you need to edit your settings.json file (Ctrl+,) and add this:

{
  "files.eol": "\n"
}
Andre Pena
  • 56,650
  • 48
  • 196
  • 243