0

To see all of the git config values you can use:

git config --list --show-origin

My question is this. If core.autocrlf shows up multiple times (some true and some false). Which value is actually being used? Is there a command that shows you the "effective" git config value being used for every config value?

Searching I found:

NOTE: It appears by experimentation that

git config --get core.autocrlf

Gives me the effective value (for the one config property core.autocrlf).

Is there a command that gives you the effective value for all config properties?

PatS
  • 8,833
  • 12
  • 57
  • 100

1 Answers1

1

If you go with git config --list, you will get all settings, global, local. For specific git project you can use

git config -l --local --show-origin

The same way with --global you could see your global settings (applied if you are not modifing any configuration for the project).

The 'magic' behind this is that there is a global settings that can be overriden by a local project settings. The most common thing is to set your email. Git wants you to set it globally first

git config --global user.email john@example.com

Then you will start a new project and this global configuration is automatically inhereted. But now you have the possibility to change it

git config user.email peter@example.com

and now you will see two user.email rows while git confg --list. The global will be the first one and the second one will be local, because it overrides the first value. Using --local git will retrieve only the final data for your local project.

  • This is good, but it doesn't appear to show the **effective values of all of the settings** . I ran `git config --list --show-origin | grep auto` and got `file:C:/Program Files/Git/etc/gitconfig core.autocrlf=true`, but when I added the `--local` option, the value for `core.autocrlf` did not appear. So `--local` seems to show my local overrides but not **all of the options** that have been set. – PatS Jul 21 '23 at 13:59
  • 1
    You are right, the `--local` takes only the values from repository, I thought it takes all, my bad. It took me a while, but I haven't found a built in solution, so you probably will have to write a shell script. First to get an array with `--global`, then `--local` and if the global line key exists in local, then override it. Also look at the `--system` settings and what priority it has. – Jimmy Found Jul 24 '23 at 06:47