网上大部分Git教程,都是通过配置全局账户方式,没有说明如何分站点使用不同账户。
比如,希望在codemonkey.cn使用codemonkey.cn账户,在github.com使用github.com账户。
现整理一份配置说明,以便参考。
Windows下的“~/.ssh/config”文件,Linux下的“~/.ssh/ssh_config”文件(“~”代表用户根目录):
1 2 3 4 5 6 7 |
Host github.com User githubAccount IdentityFile ~/.ssh/github-rsa-key Host git.codemonkey.com User codemonkeyAccount IdentityFile ~/.ssh/codemonkey-rsa-key |
参考资料:
http://blog.csdn.net/zxncvb/article/details/22153019
http://www.cnblogs.com/hustskyking/p/problems-in-git-when-ssh.html
http://elkpi.com/topics/multi-user-git-ssh-config.html
http://riny.net/2014/git-ssh-key/
http://my.oschina.net/meilihao/blog/157716
Git教程:
http://www.liaoxuefeng.com/wiki/0013739516305929606dd18361248578c67b8067c8c017b000
http://www.ihref.com/read-16369.html
http://www.yiibai.com/git/