[Git] Warning: lf will be replaced by CRLF | fatal: CRLF wocould be replaced by LF

Source: Internet
Author: User

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.autocrlfTo enable this function. If it is on Windows, set ittrueIn 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.autocrlfSet 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 setfalseCancel 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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.