为什么 'git config' 在某些情况下会创建多个配置条目?
Why does 'git config' create multiple config entries in some cases?
我试图设置一些 git 别名,发现 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.
我想知道为什么 git 在第二种情况下存储多个值,什么时候有用?
导致你"wtf"的最后一个"extra"参数是value_regex,详见文档:https://git-scm.com/docs/git-config
可以使用多个值,例如要添加多个获取 refspec,请参见此处的示例:https://git-scm.com/book/en/v2/Git-Internals-The-Refspec
我的 Git 配置中有这个:
[include]
path = ~/.gitconfig_user
path = ~/.gitconfig_os
这允许我从外部文件的 Git 配置块中组成我的配置。我猜想,为了保持一致性,Git 允许您为任何键指定多个值,但它们只对一组特定的消费者有意义。
我试图设置一些 git 别名,发现 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.
我想知道为什么 git 在第二种情况下存储多个值,什么时候有用?
导致你"wtf"的最后一个"extra"参数是value_regex,详见文档:https://git-scm.com/docs/git-config
可以使用多个值,例如要添加多个获取 refspec,请参见此处的示例:https://git-scm.com/book/en/v2/Git-Internals-The-Refspec
我的 Git 配置中有这个:
[include]
path = ~/.gitconfig_user
path = ~/.gitconfig_os
这允许我从外部文件的 Git 配置块中组成我的配置。我猜想,为了保持一致性,Git 允许您为任何键指定多个值,但它们只对一组特定的消费者有意义。