git-多账户配置

两个方面要做

1.配置ssh

这样就能使用ssh连接,不用输账号密码啦

1.1 生成两份公钥,分别放到多个账户里(用一个公钥应该也可以,但是不安全,不推荐这样做)

1.2配置git文件 .ssh/config

host github.com
    Hostname github.com
    User icecrea
    IdentityFile ~/.ssh/id_rsa_github


host gitlab.com
    Hostname gitlab.com
    User xxx
    IdentityFile ~/.ssh/id_rsa

  

2.配置git

git里可以设置,在某个文件夹下,使用另外一套配置.

[user]
        name = ***
        email = *******

[includeIf "gitdir:****"]
    path = ~/.gitconfig_self

然后在gitconfig_self中再定义另外一套git配置即可

原文地址:https://www.cnblogs.com/zyhe/p/15059487.html