使用多个github账号管理仓库
操作方法
- 打开终端或者git Bash
- 生成公钥和私钥 - 1 
 2- $ ssh-keygen -t rsa -f ~/.ssh/id_rsa_1 -C "one@gmail.com" 
 $ ssh-keygen -t rsa -f ~/.ssh/id_rsa_2 -C "two@gmail.com"
- 创建 - config文件- 1 - touch config 
- 在 - config文件中添加如下内容
| 1 | # one(one@gmail.com) | 
- 部署SSH key
 分别登陆两个github账号,进入Personal settings –> SSH and GPG keys,将对应的.pub中的内容添加进去。
- 测试 SSH链接 - 1 
 2- ssh -T git@one.github.com 
 ssh -T git@two.github.com
- 进入仓库中设置用户 - 1 
 2
 3
 4
 5
 6
 7
 8
 9
 10- # 取消全局 用户名/邮箱 配置 
 git config –global –unset user.name
 git config –global –unset user.email
 # 单独设置每个repo 用户名/邮箱
 git config user.email “one@gmail.com”
 git config user.name “one”
 git config user.email “two@gmail.com”
 git config user.name “two”
备注
如果是使用hexo建博客,第7部应在.deploy_git文件夹中进行,或直接修改.deploy_git\.git中的config文件,添加以下内容:
| 1 | [user] |