美文网首页
配置多个Git账户

配置多个Git账户

作者: V7hinc | 来源:发表于2020-10-14 18:02 被阅读0次

生成密钥

ssh-keygen -t -C "xxx@xxx.com"
# 多个账户生成多次
Generating public/private rsa key pair.
Enter file in which to save the key (/c/Users/admin/.ssh/id_rsa): 这个地方路径名称需要改,如/c/Users/admin/.ssh/id_rsa_gitlab
# 主要是避免文件名重复产生覆盖

在~/.ssh/目录下创建config文件
内容编辑如下:

# 网站的别名,可以随便填写
Host github.com
# 托管网站的域名,需要真实的git网站域名
HostName github.com
# 配置使用用户名 
User V7hinc
# 这里是id_rsa的目录位置 
IdentityFile ~/.ssh/id_rsa_github

# 另一个git网站
Host gitlab.com
HostName gitlab.com
User xxx
IdentityFile ~/.ssh/id_rsa_gitlab
# 如果ssh端口不是22,可以加上这条指定ssh端口
Port 2222

相关文章

网友评论

      本文标题:配置多个Git账户

      本文链接:https://www.haomeiwen.com/subject/lqbwpktx.html