我建立了一个工作和个人github帐户。 为了区分它们,我在 ~/.ssh 中创建了一个配置文件:
Host workusername.github.com
HostName github.com
PreferredAuthentications publickey
IdentityFile ~/.ssh/id_rsa
Host personalusername.github.com
HostName github.com
PreferredAuthentications publickey
User personalusername
IdentityFile ~/.ssh/id_rsa_personalusername
我保存了配置并输入
git config user.name "personalusername">
令我沮丧的是,提交看起来像:
personalusername <workemail>
git 用户名与我在 github.com 设置中指定的用户名无关。
git config user.email personalemail。 关闭终端,然后再次打开。