git · Git
The message
warning: LF will be replaced by CRLF in package.json.
What it means
This is a notice, not an error: core.autocrlf is on, so git stores LF in the commit but will write CRLF into your working copy. Installing git on Windows with the defaults sets autocrlf to true, so it appears on every add on that machine. git config core.autocrlf input stores LF and stops converting on checkout, and the better answer is a .gitattributes in the repository containing * text=auto eol=lf, so every clone behaves the same. Changing the setting can make every file look modified once; that is a single re-checkout, not lost work.
The fix
git config core.autocrlf input- Printed by
- git
- Git
- 29
Almost every git error is a refusal that means "doing that from this state would lose something"; fatal: means git stopped without changing anything, and the hint: lines under the first line usually carry the actual remedy.
Reading an error message
- Read from the first line down. The lower you go the more it is about the tool’s internals; the cause is usually at the top.
- If there is a file and a line number, start there — not the top stack frame, but the topmost line that names a file you wrote.
- Search the message verbatim, but strip your own paths and variable names first; those are what stop the search from matching.
- The same condition is worded differently across tool versions. If results look wrong, add the version number to the query.
- Before pasting a fix, check what it throws away. Some of these cannot be undone.
Common questions
Q. What does “warning: LF will be replaced by CRLF in package.json.” mean?
This is a notice, not an error: core.autocrlf is on, so git stores LF in the commit but will write CRLF into your working copy. Installing git on Windows with the defaults sets autocrlf to true, so it appears on every add on that machine. git config core.autocrlf input stores LF and stops converting on checkout, and the better answer is a .gitattributes in the repository containing * text=auto eol=lf, so every clone behaves the same. Changing the setting can make every file look modified once; that is a single re-checkout, not lost work.
Q. How do I fix it?
git config core.autocrlf input — before running it, check the explanation above for what this command discards.
Q. Which tool prints this?
git. It sits under Git, and the message runs to 9 words.