Tag Archives: CRLF

[git] warning: LF will be replaced by CRLF

When using git in Windows 7, create a new library

git init

and then add files to the library

git add – a

but a prompt appears:

warning: LF will be replaced by CRLF ..

solution:

enter the following command in Git bash:

git config — global core.autocrlffalse (2 ‘-‘)

delete the. Git folder in the project- rf.git

re solve the problem of

git init -> “git add – a!

the following is a foreign friend’s answer in stack overflow, explaining why.

/* add at March 13, 2012*/

Git has two modes of how it treats line endings:

$ git config core.autocrlf # that command will print either "true" or "false" 

You can set the mode to use by adding an additional parameter oftrueorfalseto the above command line.

Ifcore.autocrlfis set to true, that means that any time you add a file to the git repo that git thinks is a text file, it will turn all CRLF line endings to just LF before it stores it in the commit. Whenever yougit checkoutsomething, all text files automatically will have their LF line endings converted to CRLF endings. This allows development of a project across platforms that use different line-ending styles without commits being very noisy because each editor changes the line ending style as the line ending style is always consistently LF.

The side-effect of this convenient conversion, and this is what the warning you’re seeing is about, is that if a text file you authored originally had LF endings instead of CRLF, it will be stored with LF as usual, but when checked out later it will have CRLF endings. For normal text files this is usually just fine. The warning is a “for your information” in this case, but in case git incorrectly assesses a binary file to be a text file, it is an important warning because git would then be corrupting your binary file.

Ifcore.autocrlfis set to false, no line-ending conversion is ever performed, so text files are checked in as-is. This usually works ok, as long as all your developers are either on Linux or all on Windows. But in my experience I still tend to get text files with mixed line endings that end up causing problems.

My personal preference is to leave the setting turned ON, as a Windows developer.

http://stackoverflow.com/questions/1967370/git-replacing-lf-with-crlf