SedationH Avatar

Git技巧:一个机器,搞不同仓库

Published on May 28, 2023Updated on March 23, 2024

关键能力

  1. 密钥对的区分
  2. 信息的区分「name、email」

密钥对的区分

利用 host 去找 对应的 IdentityFile

~/.ssh/config

CODE
# Work ByteDance
 Host code.byted.org
 IdentityFile ~/.ssh/bytedance

# Personal GitHub account
 Host *.github.com
 IdentityFile ~/.ssh/id_rsa

信息的区分「name、email」

~/.ssh/config

CODE
[user]
    name = SedationH
    email = sedationh@gmail.com
[includeIf "gitdir:~/workspace/bytedance/"]
     path = ~/workspace/bytedance/.gitconfig

~/workspace/bytedance/.gitconfig

CODE
[user]
    email = xxx@xx.email
    name = xxx