windows git多账户配置

初始化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

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值