第一步:ssh-keygen -t rsa -C "<GitHub邮箱>" -f ~/.ssh/id_rsa_github
生成两个私钥
第二步:git私钥存放位置看是否存在config文件 没有创建一个 配置如下
Host company #可以理解成配置编号
HostName github.com #平台地址
#RSAAuthentication yes #是否默认 注销就行
PreferredAuthentications publickey
IdentityFile ~/.ssh/id_rsa #私钥的位置
Host github.com
HostName github.com
#RSAAuthentication yes
PreferredAuthentications publickey
IdentityFile /c/Users/zyx/.ssh/id_rsa
提交时 正常情况下 例如:git push git@github.com/xxxxx
修改为 git push git@配置编号/xxxxxx
例如:
git push git@company/xxxxxx 公司账号github
git push git@github.com/xxxxxx 私人github账号
ps: 项目目录下的.git/config 中的url 参数记得配置正确