So far as I’ve observed, when multiple values are specified to a git config variable in one scope or in multiple scopes, the variable falls into one of the two groups. One uses the last value and the other uses all the values.
git config --system user.name foo
git config --global user.name bar
git commit
uses bar
as the committer name. The global user.name
overwrites the system-wide one.
git config --global remote.origin.fetch +refs/heads/*:refs/remotes/origin/*
git config --local remote.origin.fetch +refs/heads/*:refs/remotes/origin2/*
git fetch origin foo
updates/creates both refs/remotes/origin/foo
and refs/remotes/origin2/foo
. Both the global and the local values are used.
For a random config variable, is there a programmatic method to find into which group it falls?
To be more clear, I look for a method to find if the value of the highest precedence takes effect or all of the multiple values take effect.
This is not possible.
It is not even the case that the category is fixed for a given variable. For example, given the global and local settings as in your post, the output of
git config --get-all user.name
is
foo
bar
i.e., it is treated as multi-valued variable even though it is treated as single-value when git commit
uses it.
It depends on every case where the variable is used whether it is single-valued or multi-valued. UTSL.
1