Windows Git Users: Don't Convert Line Endings

When installing Git on Windows, it will suggest that you set line ending conversion to true, or "Checkout Windows-style, commit Unix-style line endings".

Git Install on Windows Line Ending Settings

The intent here (allow file editing w/ CRLF-only Windows tools and ensure only LF files are commited) is more than reasonable. In practice however this is somewhat misguided and unnecessary.

Automatic Conversion Leads to Strange Edge Cases

With conversion enabled, the checked-out files are in a different state than their source repository. This can lead to strange errors where build artifacts or files transferred to other systems are subtly different than those generated from the unmodified source.

Modern Editors Don't Need the Conversion

It could once be argued that rare conversion edge cases were acceptable to avoid accidentally commited CRLF files. That is no longer valid given modern editors' support for LF files.

For example, Visual Studio projects can use .editorconfig to ensure consistent file settings:

# EditorConfig is awesome:

# top-most EditorConfig file
root = true

# Unix-style newlines with a newline ending every file
end_of_line = lf
insert_final_newline = true

Disabling Conversion

Run git config --global core.autocrlf false to disable any automatic conversion. This puts the following in your global git config:


    autocrlf = false

Category Navigation: