[!NOTE|label:references:]
list
list eol in repo
$ git ls-files --eol
# list all crlf
$ git ls-files --eol | grep '/crlf'
# list all lf which not been controlled by gitattributes file
$ git ls-files --eol | grep -E '[iw]/lf' | grep -v -E 'attr/.+eol='
or
$ find . -type f -exec sh -c "file {} | grep 'with CRLF'" \; # or $ find . -type f -follow -print0 | xargs -0 file | grep 'with CRLF' # or get file list $ find . -type f -exec sh -c "file {} | grep 'with CRLF'" \; | awk -F':' '{print $1}'
list config
- get all config :
--get-all$ git config --show-origin --show-scope --get-all core.autocrlf global file:/home/marslo/.gitconfig false local file:.git/config input get active config :
--get$ git config --show-origin --show-scope --get core.autocrlf local file:.git/config inputcore.eol$ git config --show-origin --show-scope --get core.eol global file:/home/marslo/.gitconfig lf $ git config --show-origin --show-scope --get-all core.eol global file:/home/marslo/.gitconfig lfcore.safecrlf$ git config --show-origin --show-scope --get-all core.safecrlf global file:/home/marslo/.gitconfig warn
check one by one
worktree
$ git config --worktree --show-scope --show-origin --get-all core.autocrlf local file:.git/config inputlocal
$ git config --local --show-scope --show-origin --get-all core.autocrlf local file:.git/config inputsystem
$ git config --system --show-scope --show-origin --get-all core.autocrlfglobal
$ git config --global --show-scope --show-origin --get-all core.autocrlf global file:/home/marslo/.gitconfig false
theory
core.autocrlf
parameters
| core.autocrlf | false | input | true |
|---|---|---|---|
| git commit | lf > lf cr > cr crlf > crlf |
lf > lf cr > cr crlf > lf |
lf > lf cr > cr crlf > lf |
| git checkout | lf > lf cr > cr crlf > crlf |
lf > lf cr > cr crlf > crlf |
lf > lf cr > cr crlf > crlf |
core.autocrlf=true: core.autocrlf=input: core.autocrlf=false:
repo repo repo
^ V ^ V ^ V
/ \ / \ / \
crlf->lf lf->crlf crlf->lf \ / \
/ \ / \ / \
set in GUI

checkout Windows-style, commit Unix-style line endings:
$ git config --global core.autocrlf true- Text files checked-out from the repository that have only
LFcharacters are normalized to CRLF in your working tree; files that containCRLFin the repository will not be touched - Text files that have only
LFcharacters in the repository, are normalized from CRLF to LF when committed back to the repository. Files that contain CRLF in the repository will be committed untouched.
- Text files checked-out from the repository that have only
Checkout as-is, commit Unix-Style line endings:
$ git config --global core.autocrlf input- Text files checked-out from the repository will keep original
EOLcharacters in your working tree. - Text files in your working tree with
CRLFcharacters are normalized toLFwhen committed back to the repository.
- Text files checked-out from the repository will keep original
Checkout as-is, commit as-is:
$ git config --global core.autocrlf falsecore.eoldictatesEOLcharacters in the text files of your working tree.core.eol = nativeby default, which means WindowsEOLsareCRLFand *nixEOLsareLFin working trees.- Repository gitattributes settings determines
EOLcharacter normalization for commits to the repository (default is normalization toLFcharacters).
please notice
eolThis attribute sets a specific line-ending style to be used in the working directory. It enables end-of-line conversion without any content checks, effectively setting the text attribute. Note that setting this attribute on paths which are in the index with CRLF line endings may make the paths to be considered dirty. Adding the path to the index again will normalize the line endings in the index.
practice
force using lf in both remote and local
$ git config core.eol lf
$ git config core.autocrlf input
- or
$ git config --global core.eol lf $ git config --global core.autocrlf input
ignore warning: LF will be replaced by CRLF
$ git config --global core.safecrlf false