git 中,有时在使用以下命令行时

$ git config --global user.name "Your Name"
$ git config --global user.email "email@example.com"

报下面的错误:

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 config --list// 这条指令可以查看到 git 相关配置信息,可以看到已经无意间添加了多个 name 值

这时,发现是因为user.name有多个值导致的

core.symlinks=false
core.autocrlf=true
core.fscache=true
color.diff=auto
color.status=auto
color.branch=auto
color.interactive=true
help.format=html
rebase.autosquash=true
http.sslcainfo=E:/Program Files/Git/mingw64/ssl/certs/ca-bundle.crt
credential.helper=manager
user.name=*********
user.name=**
user.email=*********
解决方法:
$ git config --global --replace-all user.name "你的 git 的名称"
$ git config --global --replace-all uesr.email "你的 git 的邮箱"

做完这一步,再键入 $ git config --list 会发现 name 和 email 只有一个值了,这时候就不会报错了。

Logo

旨在为数千万中国开发者提供一个无缝且高效的云端环境,以支持学习、使用和贡献开源项目。

更多推荐