Search code examples
gitcore.autocrlf

Why is GIT not replacing CRLF with LF on writing to the working directory, although core.autocrlf is set to input?


Recently I fiddled around with gits option core.autocrlf und set it to input. I tested if the configuration parameter is set correctly:

$ git config --global core.autocrlf
input

$ git config core.autocrlf
input

Then to test gits behavior I deleted all contents of the project folder (except of course the folder .git) and made a

git reset --hard HEAD

But my editor tells me, the line endings ares still CRLF.

Why?

(I am on Ubuntu and use Atom as editor. The editors statement seems to be valid, as when I tell it to change all line endings to LF, git tells me that every line of the file was changed.)

To understand more about the whole topic i read this enlighting article:

Mind the End of Your Line


Solution

  • core.autocrlf=input will only adopt file endings when adding them to the index (and commiting them).

    It will not modify the files on the way to the workspace. You would need to use true for that - and mostly for older Mac and Windows where the native line ending is not LF.

    But most likely .gitattributes is the better system for you, as discussed in the article you mentioned.