[git] warning: LF will be replaced by CRLF | fatal: CRLF would be replaced by LF

Explain the function of static keyword and final keyword in Java in detail>>>

These two errors were encountered because of GIT’s newline check function


Git provides a newline check function ( core. Safecrlf ), which can check whether files are mixed with different styles of newline when they are submitted. The options for this function are as follows:

false – no check

warn – check and warn when submitting

true – check when submitting and reject if mixed use is found

The most stringent true option is recommended


If you’re writing programs on windows, or you’re working with other people who are programming on windows, and you’re 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 open this function. If it is on Windows system, set it to true , so that LF will be converted to CRLF when checking out the code

$ git config --global core.autocrlf true

Linux or MAC systems use lf as the line terminator, so you don’t want git to automatically convert when you check out a file; When a file with CRLF as the line terminator is accidentally introduced, you must want to correct it. Set core. Autocrlf 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

Similar Posts: