我们使用一台电脑的时候,很可能配置多个git账号(此教程默认已经配置好一个git账号)
1. 删除全局user信息
--取消全局配置
git config --global --unset user.name
git config --global --unset user.email
2.生成新的邮箱对应的sshkey
ssh-keygen -t rsa -C "xxx.com" -f /c/Users/Administrator/.ssh/id_rsa_two
注意后面的地址 默认是在这里的
3.将生成的公钥信息配置的远程仓库上
4.创建.ssh/config文件
# 默认github账号
Host github
HostName github.com
IdentityFile C:\Users\Administrator\.ssh\id_rsa
# github账号2
Host github_two
HostName github.com
IdentityFile C:\Users\Administrator\.ssh\id_rsa_two
说明:
# 注释
Host 为域名别名
Hostname:真实地址
User:用户名
IdentityFile:rsa存放地址
5.每次创建新项目的时候都要配置user信息
创建文件夹 进入文件夹 右击选择git bash here
git config --unset user.name "xxx"
git config --unset user.email "xxx"
git remote add origin xxx
参考链接:https://blog.csdn.net/u010132177/article/details/104825446/
https://www.jianshu.com/p/20d089e538ce
https://www.cnblogs.com/cangqinglang/p/11727867.html