Phil for Humanity Phil for Humanity
A Guide for the Survival of Humankind and Helping the World, Society, and Yourself.

Git CRLF Warning Message

A lot of Git users see this warning message whenever they modify files, especially on Windows.

warning: LF will be replaced by CRLF in FILENAME

Basically, this warning message is saying that all the linefeeds (LF) in the file will be converted to carriage return linefeeds (CRLF) to better support Windows file types.

Most people and applications do not care what type of linefeed is used. Fortunately, there are a few ways to prevent this issue from happening.

First and most recommended, when first installing or upgrading to a newer version of Git, users can select the option called "Checkout as-is, commit as-is". This means to keep all files in their current file format, including not changing the linefeeds.

Alternatively, users can change their configuration to turn off this "autocrlf" feature. But first, view the current configuration by using this command:

git config --get core.autocrlf

If it is set to true, then change this configuration to false by using this command:

git config --global core.autocrlf false

Alternatively, users can directly edit their configuration file, located at ~/.gitconfig, in any text editor. Here is an example file:

$ cat ~/.gitconfig
autocrlf = true
safecrlf = false

Finally, verify that the value was correctly changed to false by viewing the current configuration by using the same command as before, like this:

git config --get core.autocrlf

Unfortunately, some users still have a problem even with this change (I think newer versions of Git do not have this issue), so it may be also necessary to edit this global configuration file, located at /etc/gitconfig. Here is an example of this file:

$ cat /etc/gitconfig
symlinks = false
autocrlf = true

That’s it. Git should not give you those CRLF warning messages any more.

by Phil for Humanity
on 20140829

Related Articles
 » UNIX Warning Message: could not open /dev/kbd
 » Git Log Warning
 » ClearCase Support: Automate Checking of ClearCase Server Log Files