1.同一台电脑可以有2个git账号(不同网站的)
首先不同网站,当然可以使用同一个邮箱,比如我的 github,gitlab,bitbucket的账号都是gotodiscuss[at]gmail.com 这时候不用担心密钥的问题,因为这些网站push pull 认证的唯一性的是邮箱 比如我的windows 上 2个账号一个gitlab 一个github (用的都是id_rsa)
host github
hostname github.com
Port 22
host gitlab.ikeepstudying.com
hostname gitlab.ikeepstudying.com
Port 65095
不需要指定key的位置。因为默认读取id_rsa了
这样子使用起来没有任何区别,remote 也想平时一样操作即可。因为邮箱是相同的。
2.同一台电脑有2个github账号?咋办
比如我服务器上模拟的2个用户
#gotodiscuss@gmail.com 我在gitlab的第一个账号gotodiscuss
host gitlab.gotodiscuss.com
hostname gitlab.gotodiscuss.com
Port 65095
User gotodiscuss
IdentityFile /home/suzie/.ssh/id_rsa
# 我在gitlab的第2个账号test
host gitlab-test.gotodiscuss.com
hostname gitlab.gotodiscuss.com
Port 65095
User test
IdentityFile