git config showing duplicate entries

Issue

When I do a git config -- I see the following (abridged) list:

$ git config --list
...
core.autocrlf=true
...
core.safecrlf=true
core.autocrlf=true
...

Notice core.autocrlf=true is repeated. I then try setting their values to false “globally” with git config --global core.autocrlf false and only the 2nd instance changes:

$ git config --list
...
core.autocrlf=true
...
core.safecrlf=true
core.autocrlf=false
...

I see that using the –show-origin flag clarifies the source of each:

file:"C:\\ProgramData/Git/config"       core.autocrlf=true
file:C:/Users/schmoejoe/.gitconfig      core.autocrlf=true

And that answer also notes the order of precedence (local > global > system). So my question is: Is there a way to change the values for each of these from the command line (whether with separate commands or all at once)?

Solution

According to the documentation:

If not set explicitly with –file, there are four files where git config will search for configuration options:…

The files are read in the order given above, with last value found taking precedence over values read earlier. When multiple values are taken then all values of a key from all files will be used.

Note that you can get this documentation by typing

git help config

or by googling "git config".

Answered By – Code-Apprentice

This Answer collected from stackoverflow, is licensed under cc by-sa 2.5 , cc by-sa 3.0 and cc by-sa 4.0

Leave a Reply

(*) Required, Your email will not be published