0

What exactly should I write in the terminal to global config my git to save all files always with line endings = LF. I work on Windows but most of my co-workers use macOS and I want to save all my work on my PC with line endings = LF setting

I found this tutorial Dealing with line endings - GitHub help, but I still don't know what command should I put in the terminal to configure git to save all cloned projects on my drive with that setting.

Can you please help me?

I tried:

git config --global core.autocrlf true
git config --global core.autocrlf true text eol=lf

And it didn't work.

John Taylor
  • 729
  • 3
  • 11
  • 22

1 Answers1

2

If your editor uses CRLF:

git config --global core.autocrlf true

If your editor uses LF:

git config --global core.autocrlf input

You can also use a .gitattributes file in each project to save certain types with certain line endings. I use something like this because git will try to convert the crlf byte sequence in say images if you use * eol=lf

*.php eol=lf
*.scss eol=lf
*.sass eol=lf
*.css eol=lf
*.js eol=lf
*.json eol=lf
*.sql eol=lf
phd
  • 82,685
  • 13
  • 120
  • 165
pucky124
  • 1,489
  • 12
  • 24
  • It's worth noting that `* text=auto eol=lf` does not try to convert the CRLF byte sequence in non-text files, as of Git 2.10. https://stackoverflow.com/a/40977008/1009155 In other words: It leaves line endings unchanged on checkout, but converts CRLF to LF on text files only when committing. So it is a good option given that most Windows apps can now handle LF line endings. – David P Jun 13 '19 at 03:24
  • In other words, `* text=auto eol=lf` in **.gitattributes** is equivalent to `core.autocrlf input` in git config. Similarly, `* text=auto` in **.gitattributes** is equivalent to `core.autocrlf true`. – David P Jun 13 '19 at 03:36