About the different line breaks between Windows and Linux

background

Under each operating system, the newline characters used in text files are different. UNIX/Linux uses  0x0A(LF), early Mac OS uses 0x0D(CR), and later OS X is consistent with UNIX after changing the kernel. But DOS/Windows has always used  0x0D0A(CRLF) for newlines. Git provides a "newline automatic conversion" feature. This feature is in "auto mode" by default, when you are checking out a file, it tries to replace UNIX newlines (LF) with Windows newlines (CRLF); when you commit files, it tries to replace CRLF with LF. Git's "automatic newline conversion" feature sounds smart and sweet, as it tries to keep files in the repository consistent (UNIX-style) and compatible with local files (Windows-style). Unfortunately, this feature is buggy and unlikely to be fixed anytime soon.

 

In eclipse, set the newline character of Unix for newly opened files

Window-> preferences->Genernal->workspace 下




 

 

There is also a problem with newlines when using git in Windows

 

solve

1.Git settings:

git config --global core.autocrlf false

git config --global core.safecrlf true

Meaning:

AutoCRLF #Convert

to LF when submitting, and convert to CRLF when checking out
git config --global core.autocrlf true  

#Submit Convert to LF when checking out, not convert when checking out
git config --global core.autocrlf input #Do  

not convert
git config --global core.autocrlf false

SafeCRLF #Refuse

to submit files containing mixed newlines
git config --global core.safecrlf true #Allow  

submission of files containing mixed newlines
git config --global core.safecrlf false #Give  

a warning when submitting files containing mixed newlines
git config --global core.safecrlf warn

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326176358&siteId=291194637