关键的user.name Git有多个值 [英] More than one value for the key user.name Git
问题描述
出于某种原因,当我尝试为我的git帐户设置user.name时,出现错误关键用户名的多个值。
更新(2012年12月)
$ b如何将其设置为单个名称? $ b
git1.8.1rc1 现在运行方式不同:
git config --get用于诊断相同配置文件中多个相同变量的定义是否存在错误,但现在应用最后一个胜利由内部配置逻辑使用的规则。
严格地说,这可能是API回归,但预计在实践中没有人会注意到它。
原始答案(2010年11月)
配置手册页提到:
$ b
变量名不区分大小写,只允许使用字母数字字符和 - 。
给定变量可以有多个值;我们说变量是多值的。
实际上,这样的配置设置(有多个可能的值)被称为 multivar
正如Jefromi所建议的那样,看看3个配置文件中有多个 user.name
line。
您可以像这样查询多个值:
git config --get -all user.name #local repo git config文件)
git config --global --get-all user.name #user config文件)
git config --system --get-all user。名称#system git配置文件)
一个配置文件可以回答多个 user.name
值需要修复。
来自评论:
检查文件local,global和settings我只能看到一个
user.name
全局。
但是git config --list
和git config --get-all user.name
给了我两次
正如我在,您可以使用(查看所有 )设置:
git config -l --show-origin
你可以看到重复设置(local,global,system)的位置,你可以使用 git config [--local / - global / - system] --replace-all key value
,如 mb21 的 answer 。
For some reason I'm getting the error that "More than one value for the key user.name" when I try to set the user.name for my git account. How can I set it to a single name?
Update (December 2012)
git1.8.1rc1 now operates differently:
"git config --get" used to diagnose presence of multiple definitions of the same variable in the same configuration file as an error, but it now applies the "last one wins" rule used by the internal configuration logic.
Strictly speaking, this may be an API regression but it is expected that nobody will notice it in practice.
Original answer (November 2010)
The git config man page mentions:
The variable names are case-insensitive and only alphanumeric characters and - are allowed.
There can be more than one value for a given variable; we say then that variable is multivalued.
Actually, such config settings (with multiple possible values) are called multivar
As Jefromi suggests, see in what of the 3 config files you have more than one user.name
line.
You can query multiple values like so:
git config --get-all user.name #local repo git config file)
git config --global --get-all user.name #user config file)
git config --system --get-all user.name #system git config file)
The one config file which answers more than one user.name
value needs to be fixed.
From the comments:
Examining files "local", "global" and "settings" I can see only one
user.name
in global.
Butgit config --list
andgit config --get-all user.name
gives it twice to me
As I mention in here with Git 2.8 (March 2016), you can use (to see all settings:
git config -l --show-origin
One you see where the duplicate setting is (local, global, system), you can use git config [--local/--global/--system] --replace-all key value
, as in mb21's answer.
这篇关于关键的user.name Git有多个值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!