同一个电脑连接多个github账户的问题

生成 新的ssh-key,

$ssh-keygen -t rsa -C "[email protected]"

根据 提示设置相应 的文件 路径 及名称
拷贝id_rsa_new.pub的内容 , 在相应 的github账户上设置
执行:

ssh-add ~/.ssh/id_rsa_new

如果不配置下面的config文件 ,每次登录上去后都 需要 输入上面 的命令
配置~/.ssh/config

#建一个github别名,新建的帐号使用这个别名做克隆和更新
Host github_new
HostName github.com
User git
IdentityFile ~/.ssh/id_rsa_new.pub

在clone的时候 ,把github.com 改成 github_new,即可自动识别相应 的ssh-key
且可以 不需要 输入ssh-add 命令

你可能感兴趣的:(问题及解决,git)