码迷,mamicode.com
首页 > 其他好文 > 详细

一台电脑使用多个git账号

时间:2018-10-02 20:43:40      阅读:194      评论:0      收藏:0      [点我收藏+]

标签:查看   conf   ber   解决   cti   config   xxx   not   ica   

最近开始使用git,今天又新建了一个github账号,提交是发现总是说第一个账号没有权限,后发现git push的时候需要区分github账号,现记录解决方案:

1.创建SSH KEY  $ ssh-keygen -t rsa -C "your_email@example.com",根据提示输入文件名,如id_rsa_two,粘贴复制到github的SSH

 

2.查看用户~/.ssh下是否存在 config文件,如不存在使用命令 touch config创建,然后配置config

#github server one
Host github
Hostname github.com
User git
IdentityFile ~/.ssh/id_rsa
#github server two
Host github_two
Hostname github.com
User git
IdentityFile ~/.ssh/id_rsa_two

3.测试配置,测试成功后github ssh处小钥匙图标会变绿色

   ssh -T git@gihub_two   

   #如果配置正确会提示

   Hi your git account two in github ! You‘ve successfully authenticated, but GitHub does not provide shell access.

4.clone项目到本地

原先操作:  git clone git@github.com:yourAccount/xxx.git;

现改为:git clone git@github_two.com:yourAccount/xxx.git 

一台电脑使用多个git账号

标签:查看   conf   ber   解决   cti   config   xxx   not   ica   

原文地址:https://www.cnblogs.com/seanchang/p/9737446.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!