Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Git core.autocrlf line ending default setting

I'm trying to figure out what is the default value for core.autocrlf in Git if the user doesn't change this setting.

I've looked in the docs but can't find this info. Can you please point me in the right direction?

Specifically, on a fresh Git install, would Git automatically convert Windows line endings to Unix when committing to a repo from a Windows system?

Thanks!

like image 412
Pensierinmusica Avatar asked Sep 09 '16 09:09

Pensierinmusica


People also ask

What is default value for core Autocrlf?

the default value is "false" Windows installer let you choose the desired behavior but by default (if you install without changing proposed settings) it sets it to "true".

Should I use CRLF or LF?

Whereas Windows follows the original convention of a carriage return plus a line feed ( CRLF ) for line endings, operating systems like Linux and Mac use only the line feed ( LF ) character. The history of these two control characters dates back to the era of the typewriter.

What is git line ending?

eol = native The default. When Git needs to change line endings to write a file in your working directory it will change them to whatever is the default line ending on your platform. For Windows this will be CRLF , for Unix/Linux/OS X this will be LF .


2 Answers

Checking the git source code, core.autocrlf is set to false by default. (And has been since the property's original introduction on Feb 13, 2007, though it has since been converted from a static value to a constant.)

The Windows installer does require you to pick a value for this property which is explicitly set in the git system config.

like image 157
LightBender Avatar answered Nov 06 '22 22:11

LightBender


It is difficult to find this stated but I could figure out by trial and error that:

  • the default value is "false"

  • Windows installer let you choose the desired behavior but by default (if you install without changing proposed settings) it sets it to "true". This is not the software default, the installer sets the core.autocrlf system setting.

"false" means no processing on line endings "true" means checking in as LF and checking out according to system (CRLF on Windows and LF on Unix).

When Unix and Windows are both used it is advisable to use "false" on Unix (because automatic conversion can break some binary files that looks like text files and Unix uses LF anyway) and "true" on Windows (otherwise the repository is filled with CRLF which is causing compatibility issues).

like image 23
Claudio Avatar answered Nov 06 '22 22:11

Claudio