初始化git项目
git init
配置git邮箱和用户名
git config user.name "wanghuilong"
git config user.email "822308952@qq.com"
##查看
git config user.name
生成两个公钥私钥
第一个
ssh-keygen -t rsa -C "822308952@qq.com"
会提示默认提示
Enter file in which to save the key (/c/Users/123/.ssh/id_rsa):/c/Users/123/.ssh/id_rsa_my
/c/Users/123/.ssh/id_rsa 是默认存储路劲和文件名
在冒号后面改成自己的别名
例如: /c/Users/123/.ssh/id_rsa_my
然后回车就可以了
第二个
ssh-keygen -t rsa -C "922308953@qq.com"
Enter file in which to save the key (/c/Users/123/.ssh/id_rsa):/c/Users/123/.ssh/id_rsa_you
在/c/Users/123/.ssh/ 下面会生成四个文件
id_rsa_my
id_rsa_my.pub
id_rsa_you
id_rsa_you.pub
在/c/Users/123/.ssh/ 下面新建名为config文件没有后缀
Host gitee.com
HostName gitee.com
IdentityFile C:\\Users\\123\\.ssh\\id_rsa_you
PreferredAuthentications publickey
User 汪会龙
# 配置
Host gitee.com1
HostName gitee.com
IdentityFile C:\\Users\\123\\.ssh\\id_rsa_my
PreferredAuthentications publickey
User wanghuilong
原理 :通过 Host别名找到来确认真正的服务器地址HostName和认证文件IdentityFile
去git码云添加d_rsa_you.pub里面的公钥打开赋值即可
登陆->点击右上角头像->设置->安全设置->添加SSH公钥
在各自项目添加远程仓库
git remote add origin git@gitee.com1:michaelliao/learngit.git
git remote add origin git@gitee.com:michaelliao/learngit.git
注意以上标红的服务器是config里面的Host
查看远程仓库
git remote -v
删除远程仓库
git remote rm origin
最后
git pull origin master
git push origin master
git clone 地址
参考链接:
https://www.cnblogs.com/popfisher/p/5731232.html
https://blog.csdn.net/baidu_35738377/article/details/54580156