Git Reference ยท Configuration Options
core.autocrlf setting
Reference for core.autocrlf: what true, input and false do to CRLF and LF line endings on add and checkout, and why a .gitattributes file is safer.
core.autocrlf is Git's older, user-level switch for line-ending conversion. Windows editors traditionally end lines with CR LF, Linux and macOS with LF alone. Repositories shared between both are happiest when the committed blobs use LF only; autocrlf makes Git translate on the way in and, optionally, on the way out.
It takes three values. true converts CRLF to LF when files are added and LF to CRLF when they are checked out. input converts only on the way in. false, the default, converts nothing.
git config --global core.autocrlf true # Windows git config --global core.autocrlf input # Linux and macOS git config --global core.autocrlf false # leave bytes alone
Try it
Press Run (or Ctrl + Enter) to see the result here.
Program input ยท what you'd type while the program runs
Type the answers before you press Run, one per line. Each time the program reads a line (with read or cat), it gets the next line from this box.
Press Run (or Ctrl + Enter) to see the result here.
Program input ยท what you'd type while the program runs
Type the answers before you press Run, one per line. Each time the program reads a line (with read or cat), it gets the next line from this box.
Syntax
git config [--global] core.autocrlf <true | input | false>
| Value | Add / commit | Checkout |
|---|---|---|
true |
CRLF becomes LF | LF becomes CRLF |
input |
CRLF becomes LF | no change |
false |
no change | no change |
git ls-files --eol shows the state: i/ is the line ending in the index, w/ in the working tree, and attr/ what .gitattributes requests.
Safety check: core.safecrlf (default warn) prints a warning when a conversion would not be reversible, and with true it refuses the operation.
Usage notes
- Binary files are skipped. Git detects a NUL byte and leaves the file alone, but detection is a heuristic, so mark known binaries in
.gitattributes. - A
textoreolattribute overrides this setting for the matching paths. A committed.gitattributeswith* text=autogives every contributor the same behavior regardless of their personal config, and is the recommended approach. inputis the usual choice on Unix for people who might receive CRLF files from elsewhere;trueon Windows when tools expect CRLF in the working tree.- Existing files are not rewritten when you change the setting. Run
git add --renormalize .to update the index, and refresh the working tree with a checkout. - Mixed endings in one file cause "CRLF would be replaced by LF" style warnings and noisy diffs; fix the file instead of silencing Git.
core.eolchooses the native ending used fortextfiles when noautocrlfrule applies (lf,crlfornative).- Shell scripts break with CRLF (
/bin/sh^M: bad interpreter), so force*.sh text eol=lf.