Last updated on

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

关键能力

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

密钥对的区分

利用 host 去找 对应的 IdentityFile

~/.ssh/config

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

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

信息的区分「name、email」

~/.ssh/config

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

~/workspace/bytedance/.gitconfig

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