When you encounter these two errors, you basically set autocrlf to false, but I think this is very inappropriate.
If your source file contains the LF line break and autocrlf = true, git add will encounterFatal: lf wocould be replaced by CRLF. There are two solutions:
1. Convert lf from your source file to CRLF. [recommended]
2. Set autocrlf to false.
If the source file contains the CRLF line break and autocrlf = input, git add will also encounterFatal: CRLF wocould be replaced by LF. There are two solutions:
1. Convert the CRLF in your source file into LF [recommended]
2. Set autocrlf to true or false.
My suggestion: Set autocrlf = input on Mac and autocrlf = true (default) on Windows ).
Certificate ----------------------------------------------------------------------------------------------------------------------------------
In this case,
Windows: (true)
When submitting, convert CRLF into LF and then submit;
When switching out, LF is automatically converted into CRLF;
MAC/Linux: (input)
When submitting, convert CRLF into LF and then submit;
When switching out, keep lf.
In this way, the repository will always be lf, and the Windows Workspace will be CRLF, And the MAC/Linux workspace will be LF.
Certificate ----------------------------------------------------------------------------------------------------------------------------------
Core. autocrlf
If you are writing a program on windows, or you are working with others, they are programming on windows, but you are on other systems, in which case, you may encounter an ending character at the end of a line. This is because Windows uses carriage return and line feed to end a line, while Mac and Linux only use a line break. Although this is a small problem, it will greatly disrupt cross-platform collaboration.
Git can automatically convert the line terminator CRLF to LF when you submit the code, and convert the LF to CRLF when you check out the code. Usecore.autocrlf
To enable this function. If it is on Windows, set ittrue
In this way, when the code is checked out, lf will be converted to CRLF:
$ git config --global core.autocrlf true
Linux or MAC systems use lf as the line terminator, so you do not want git to perform automatic conversion when checking out the file; when a file with the CRLF as the row Terminator is accidentally introduced, you certainly want to modifycore.autocrlf
Set it to input to tell git to convert CRLF to lf at commit, and do not convert it at checkout:
$ git config --global core.autocrlf input
In this way, CRLF will be retained in the checkout file on Windows, and LF will be retained in MAC and Linux systems, including warehouse.
If you are a Windows programmer and are developing projects that only run on Windows, you can setfalse
Cancel this function and record the carriage return in the database:
$ git config --global core.autocrlf false
[Git] Warning: lf will be replaced by CRLF | fatal: CRLF wocould be replaced by LF