同一部电脑配两个git账号

目标效果
--全局配置:公司账号
--某仓库配置:个人账号

参考:
1、生成私钥+设置config文件:https://www.cnblogs.com/lqfxyy/p/6409810.html

2、ssh-agent 添加私钥:
https://segmentfault.com/a/1190000002449006

https://www.cnblogs.com/kex1n/p/5229493.html
*** eval $(ssh-agent -s) 运行ssh-agent
*** ssh-add 私钥文件 然后才能add

该文件用于配置私钥对应的服务器

first user

Host xiefenghua@linghit.com
HostName http://git.linghit.com:666/
IdentityFile ~/.ssh/id_rsa

配置github.com

second user

Host xfh0192

HostName https://github.com/xfh0192

IdentityFile ~/.ssh/id_rsa_xfh

配置github.com

Host github.com
HostName github.com
IdentityFile ~/.ssh/id_rsa_xfh
PreferredAuthentications publickey
User xfh0192

PS:
后来尝试了,--global设置的全局 user.name 和 user.email 没什么关系。clone 和 push都可以。影响的应该是push上去显示的用户名

posted on 2017-12-28 15:23  xfh0192  阅读(106)  评论(0编辑  收藏  举报

导航