8

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?

bright
  • 4,700
  • 1
  • 34
  • 59
  • 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. – hjpotter92 Sep 27 '16 at 06:06

1 Answers1

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.

VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
  • 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... – Xavi Montero Dec 11 '16 at 17:09
  • No question needed. In fact, it is documented in the `v2` documentation here: https://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 as an admin." - CAUTION to users from Spain: When googling for [git config], it takes to https://git-scm.com/book/es/v1/Empezando-Configurando-Git-por-primera-vez which does not reflect that. – Xavi Montero Dec 11 '16 at 17:20
  • 1
    @XaviMontero Thank you. I have included your comment in the answer for more visibility. – VonC Dec 11 '16 at 19:00
  • In my case (Windows 10) the bogus config was in C:/Program Files/Git/etc/gitconfig – Jon R Oct 28 '22 at 15:53
  • 1
    @JonR Thank you for this feedback. I have included your comment in the answer for more visibility. – VonC Oct 28 '22 at 16:55