Recently, I used git to manage my last project under Windows. When I ran git add., I kept getting the error LF will be replaced by CRLF. Most of the answers on the Internet were git config --global core.autocrlf. false, disable automatic word wrapping. This does allow me to add
in this project. But the problem is that another project (code pulled down from mac) does management It must be set to true
My mind is a little crazy right now. Can someone explain in detail what exactly happened in this process?
怪我咯2017-05-02 09:34:11
Um, are you using Baidu? . . So you don’t know the cause of the problem at all, it has nothing to do with automatic line wrapping
windows newline character: CRLF Linux/UNIX newline character: LF
So of course you need to convert the carriage return character from windows to UNIX.
git config --global core.autocrlf false
Turn off line break conversion function
git config --global core.autocrlf true
It works as follows:
Git can handle this by auto-converting CRLF line endings into LF when you add a file to the index
From the official documentation
phpcn_u15822017-05-02 09:34:11
Since git was exclusive to Linux at first, line breaks have always been LF in Linux. If a project team has Linux and Windows users, then the line breaks should be unified. Of course, general files should be unified as LF. After autocrlf is turned on, the local files of Windows users will still be CR LF, automatically converted to LF when submitted.
ps: Since Windows is widely used in China, it is very possible to change Windows-specific files to LF line breaks, such as bat batch scripts. In this way, the files downloaded from github will lose the CR line breaks, resulting in the inability to run.
This setting item is redundant. It is generally recommended to turn it off and manually ensure that the line breaks are consistent. Generally, current IDEs can display multiple line break styles normally, and LF can also be displayed normally under Windows. As long as you don't edit the code with Windows Notepad, there will be no CR LF style line breaks.