github客户端切换账号

1,生成新的密钥对

$  ssh-keygen -t rsa -C [email protected]


2,把公钥添加到Github账户中


3,配置 ~/.ssh/config

Host githubuser2
    HostName github.com
    User [email protected]
    PreferredAuthentications publickey
    IdentityFile ~/.ssh/id_rsa_user2


4,配置Git全局变量


$ git config --global user.name "user2"  

$ git config --global user.email [email protected]

或者编辑 ~/.gitconfig 文件


5,查看Git配置信息

$ git config --list


6,如果在push的时候报403错误(error: The requested URL returned error: 403 Forbidden while accessinghttps://github.com/ ...)


找开项目下面的 .git/config 文件,找到 [remote "origin"],在github.com前面加上Github的用户名,如

url = https://[email protected]/chenghui/myproject.git


注:文档没有写完,步骤3可以忽略。


参考文档:http://blog.csdn.net/wirelessqa/article/details/8572928







你可能感兴趣的:(github客户端切换账号)