同一台计算机上的两个GitHub帐户 [英] Two GitHub accounts on the same computer

查看:67
本文介绍了同一台计算机上的两个GitHub帐户的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

首先,我知道这个问题已被问过几次,但我发现的所有解决方案都行不通.

First of all I know that this question has been asked and answered several times, but all solutions that I've found don't work.

任务非常简单-我有两个GitHub帐户,一个是个人帐户,第二个是企业帐户.

Task is very simple - I have two GitHub accounts, one personal and second for business.

我尝试使用一些配置,但是全部都是这样:

I tried to use a few configurations, but all were like this:

Host github.com-personal
    HostName github.com
    User kagarlickij
    IdentityFile ~/.ssh/github_kagarlickij_private

Host github.com-business
    HostName github.com
    User dmytriy-kagarlickij
    IdentityFile ~/.ssh/github_dmytriy-kagarlickij-business_private

...,它不起作用.仅在Host为github.com时有效.不是github.com-business,不是business.github.com等

... and it doesn't work. It works only if Host is github.com . Not github.com-business , not business.github.com , etc

有什么想法可以解决这个问题吗?

Any ideas how to manage this?

推荐答案

用于ssh(推/拉)访问的 User 始终是"git",而不是您的用户名.

The User for ssh (push/pull) access is always "git", not your username.

另外,您还必须在克隆URL中使用配置中的ssh别名:

Also, you must use the ssh alias from your config in the clone url:

git clone github.com-personal:kagarlickij/terraform-aws-vm.git

git clone github.com-personal:kagarlickij/terraform-aws-vm.git

如果这样做,ssh将使用主机名,用户并从相应的配置文件部分进行标识.

If you do that ssh uses the hostname, user and identify from the corresponding config file section.

这篇关于同一台计算机上的两个GitHub帐户的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆