切换Git账户的方法

虽然需求不是很大,但如果想要在一台电脑上使用多个 GitHub 帐户,并进行切换,可以按照以下方法操作。

1. 更换 SSH 密钥

Host github.com
  IdentityFile ~/.ssh/github_userA_keyA
  #IdentityFile ~/.ssh/github_userB_keyB

2. 更改电子邮件地址

[user]
  name = userA
  email = userA@example.com
  #name = userB
  #email = userB@example.com