4

Ok, so i have read all threads on this topic, and my understanding is the following:

if i set core.autocrlf = true in Windows, git should convert all my crlf line endings to LF when committing and pushing.

This is what i want, and i have my config set up as such. However, when i check in a text file with CRLF endings, i get the error messsage:

fatal: LF would be replaced by CRLF

I don't get it... shoudn't the opposite happen when i commit?

Mathias
  • 3,879
  • 5
  • 36
  • 48

1 Answers1

4

The message is misleading, but makes sense:

  1. You check in your file, line ending normalization is done: CRLF is replaced with LF, LF is kept as LF.
  2. Later on, you check out the file in question. Now git will “undo” the line ending normalization: LF will be replaced with CRLF.

At the end of that process, all the LFs in your working dir have been replaced with CRLF. That is what git is warning you about.

Note: I would not recommend using core.autocrlf – it is an old setting that has been superseded. Use attributes instead. See here: https://stackoverflow.com/a/13154031/758345

Community
  • 1
  • 1
Chronial
  • 66,706
  • 14
  • 93
  • 99