Why are there two different lines with core.autocrlf output with "git config -l"?
Asked Answered
S

1

9

I'm trying to set core.autocrlf=true. But after executing git config --global core.autocrlf true the output of git config -l shows both these lines

core.autocrlf=false
... other settings ...
core.autocrlf=true

Why is this, and how can I ensure that autocrlf gets properly set to true?

Szymanski answered 27/9, 2016 at 5:52 Comment(1)
Your system/local config has it set to false. Check repo/.git/config. If the property isn't there, then /etc/gitconfig has this.Forefend
M
20

You can know more with Git 2.8+:

git config -l --show-origin

That will give you a better idea from where those settings come from.
Local config override global settings which overrides system settings.

See a concrete example in "Where do the settings in my Git configuration come from?".

Xavi Montero points out to the Pro Book "Getting Started - First-Time Git Setup" which mentions:

If you are using version 2.x or later of Git for Windows, there is also a system-level config file at

  • C:\Documents and Settings\All Users\Application Data\Git\config on Windows XP, and
  • in C:\ProgramData\Git\config on Windows Vista and newer.

This config file can only be changed by git config -f <file> as an admin.


On Windows 10, Jon R reports the issue was in C:/Program Files/Git/etc/gitconfig.

Meaganmeager answered 27/9, 2016 at 6:56 Comment(5)
Thanks! In Windows, I got those two autocrlf settings too; and I was turning mad as the --show-origin revealed me that the setting was in file:"C:\\ProgramData/Git/config". That file adds a number of settings that did not show up neither in --system, nor --global, nor --local standardized namespaces. I'll open a question to ask why this happens...Alkalosis
No question needed. In fact, it is documented in the v2 documentation here: git-scm.com/book/en/v2/Getting-Started-First-Time-Git-Setup which says "there is also a system-level config file at C:\Documents and Settings\All Users\Application Data\Git\config on Windows XP, and in C:\ProgramData\Git\config on Windows Vista and newer. This config file can only be changed by git config -f <file> as an admin." - CAUTION to users from Spain: When googling for [git config], it takes to git-scm.com/book/es/v1/… which does not reflect that.Alkalosis
@XaviMontero Thank you. I have included your comment in the answer for more visibility.Meaganmeager
In my case (Windows 10) the bogus config was in C:/Program Files/Git/etc/gitconfigMachicolation
@JonR Thank you for this feedback. I have included your comment in the answer for more visibility.Meaganmeager

© 2022 - 2024 — McMap. All rights reserved.