These two errors were encountered because of GIT’s newline check function.
Git provides a newline checking function（ core.safecrlf ）, you can check whether the file is mixed with different styles of newline at the time of submission. The options for this function are as follows:
false - Does not do any checking
warn - check on commit and warn
true - check at commit time and reject commit if a mixup is found
The most stringent true option is recommended.
if you are writing programs on windows, or if you are working with other people who are programming on windows and you are on other systems, you may encounter end of line problems. This is because Windows uses carriage return and line feed to end a line, while Mac and Linux only use line feed. Although this is a small problem, it can greatly disrupt cross platform collaboration.
Git can automatically convert line terminator CRLF to LF when you submit, and LF to CRLF when you check out code. use core.autocrlf To turn on this function. If it is on a Windows system, set it to true, so that when checking out the code, lf will be converted to CRLF:
$ git config --global core.autocrlf true
Linux or MAC systems use lf as the line terminator, so you don’t want git to do automatic conversion when checking out a file; when a file with CRLF as the line terminator is accidentally introduced, you definitely want to fix it core.autocrlf Set to input to tell git to convert CRLF to LF when submitting and not when checking out
$ git config --global core.autocrlf input
in this way, CRLF will be retained in check-out files on Windows systems, and LF will be retained on MAC and Linux systems, including warehouses.
If you are a Windows programmer and are developing a project that only runs on windows, you can set false to cancel this function and record the carriage return in the library
$ git config --global core.autocrlf false
- [git] warning: LF will be replaced by CRLF | fatal: CRLF would be replaced by LF
- [How to Solve Error] warning: LF will be replaced by CRLF in README.md.
- Git Submit Error: The file will have its original line endings in your working directory.
- [Solved] Expected linebreaks to be ‘LF’ but found ‘CRLF’.
- Conflict between git windows and MAC newline
- [git] warning: LF will be replaced by CRLF
- [Solved] git add Error: warning: LF will be replaced by CRLF in ……
- Shell script error newline syntax error near unexpected token
- Conversion to MySQL shell script execution error $’\ R’: command not found
- syntax error near unexpected token `do [How to Solve]