refer from :https://blog.csdn.net/qq_39892503/article/details/109374201
windows git多用户配置
在安装git结束,我们通常会打开gitbash 去配置全局的账户以及邮箱git config --global user.name "jzy" // 配置全局用户名,如 Github 上注册的用户名git config --global user.email "jzy@mail.com" // 配置全局邮箱,如 Github 上配置的邮箱
现在我有两个账户,A,B,
首先清除全局用户配置
git config --global --unset user.namegit config --global --unset user.email
对每个用户生成ssh密钥对
ssh-keygen -t rsa -C “2410723051@qq.com”
ssh-keygen -t rsa -C “2410723051@qq.com”
生成密钥对的时候记得保存的的文件名要不同
否则会覆盖
然后将生成的密钥的公钥放到github上面
将私钥添加至本地
eval $(ssh-agent -s)ssh-add /c/Users/24107/.ssh/id_rsa_githubssh-add /c/Users/24107/.ssh/id_rsa_gitee
显示ssh-add -l
管理密钥
在~/.ssh下面创建config
Host giteeHostName gitee.comUser jzyIdentityFile /C/Users/24107/.ssh/id_rsa_gitee
Host githubHostName github.comUser dengjzyIdentityFile /C/Users/24107/.ssh/id_rsa_github
hostname是你仓库所在的网址 例如码云和github的官网
user是当前仓库的用户
仓库配置
git config --local user.name "" #你的名字
git config --local user.email "" #你的邮箱