Git使用过程中报错
warning: user.email has multiple values
error: cannot overwrite multiple values with a single value
Use a regexp, --add or --replace-all to change user.email.
此类作物原因,一般是多个git用户切换造成的:
解决办法
方法一:每次使用单一账户
$ git config --global --replace-all user.email "输入你的邮箱"
$ git config --global --replace-all user.name "输入你的用户名"
方法二:多账户管理,进行账户切换
第二个git账号的配置:
1、新建user2的SSH Key
#新建SSH key:
1、$ cd ~/.ssh # 切换到C:\Users\Administrator\.ssh
2、ssh-keygen -t rsa -C "mywork@email.com" # 新建工作的SSH key
# 设置名称为id_rsa_work
3、Enter file in which to save the key (/c/Users/Administrator/.ssh/id_rsa): id_rsa_work
2、新密钥添加到SSH agent中
因为默认只读取id_rsa,为了让SSH识别新的私钥,需将其添加到SSH agent中:
ssh-add ~/.ssh/id_rsa_work
如果出现Could not open a connection to your authentication agent的错误,就试着用以下命令:
ssh-agent bash
ssh-add ~/.ssh/id_rsa_work
3、修改config文件
在~/.ssh目录下找到config文件,如果没有就创建,
touch config # 创建config
如果存在的话,其实就是往这个config中添加一个Host:
4、打开新生成的~/.ssh/id_rsa2.pub文件,将里面的内容添加到GitHub后台。
可不要忘了添加到你的另一个github帐号下的SSH Key中。
clone尽量用ssh
git clone ssh