Reputation: 16065
I was trying to set up some git aliases and noticed a strange thing about git config
:
$ git config user.name foo # this stores the new name, ok
$ git config user.name bar baz # this adds a 'name = bar' entry to the config, wtf?
$ git config user.name qux
warning: user.name has multiple values
error: cannot overwrite multiple values with a single value
Use a regexp, --add or --replace-all to change user.name.
I wonder why git stores multiple values in the 2nd case and when it can be useful?
Upvotes: 0
Views: 1577
Reputation: 5151
I have this in my Git config:
[include]
path = ~/.gitconfig_user
path = ~/.gitconfig_os
Which allows me to compose my configuration from chunks of Git config from external files. I'm guessing, for consistency, Git allows you to specify multiple values for any key, but they'll only make sense for a specific set of consumers.
Upvotes: 1
Reputation: 28951
The last "extra" parameter which caused your "wtf" is value_regex, see the documenation for details: https://git-scm.com/docs/git-config
Multiple values could be used e.g. for adding multiple fetch refspecs, see an example here: https://git-scm.com/book/en/v2/Git-Internals-The-Refspec
Upvotes: 2