我想使用两个不同的 github 帐户来分开我的学校和我的私人物品.因此,我在这里找到了方法,( youtu.be/fnSRBRiQIU8 )
I want to use two different github accounts to separate my school and my personal things. So I found the methods here,(youtu.be/fnSRBRiQIU8)
我在每个帐户上成功添加了两个ssh密钥,这是我的〜/.ssh/config 文件
I successfully added two ssh keys on each account and this is my ~/.ssh/config file
# Default account Host github User git IdentityFile ~/.ssh/id_rsa # Second account Host github-SECONDARY User git IdentityFile ~/.ssh/id_rsa_secondary我试图推动它,但是没有运气.
I tried to push it but did not have luck.
在youtube视频及其书面说明中,
In the youtube video and its written instruction describe,
1. git remote add origin git@github:SECONDARY/testing.git 2. git push -u origin master我认为这是旧方法,所以我做了这样的新方法
I thought it is old way, so I did new way like this
3. git remote add origin github/SECONDARYusername/testing.git 4. git push -u origin master然后我收到了此错误消息
Then I got this error message
fatal: 'origin' does not appear to be a git repository fatal: Could not read from remote repository. Please make sure you have the correct access rights and the repository exists.第1行和第3行不相等吗?还有其他方法可以在一台计算机上使用两个帐户吗?谢谢!
Aren't line 1 and 3 equivalent? Is there other method that I can use two accounts on one machine? Thanks!
推荐答案基本技术是使用两个新的虚拟(即假)主机名配置SSH.它们都指向github,但是一个使用一个密钥,另一个使用另一个密钥.您的ssh配置有问题,它没有指定真正的主机是什么.
The basic technique is to configure SSH with two new virtual (ie. fake) host names. They both point at github, but one uses one key and the other use the other. Your ssh config has a problem, it doesn't specify what the real host is.
# Second account Host github-SECONDARY User git IdentityFile ~/.ssh/id_rsa_secondary说当您尝试连接到github-SECONDARY时,请使用〜/.ssh/id_rsa_secondary中的ssh密钥".但是github-SECONDARY不是真实的.您需要通过添加 HostName 行来告诉ssh.
That says "when you try to connect to github-SECONDARY, use the ssh key in ~/.ssh/id_rsa_secondary". But github-SECONDARY isn't real. You need to tell ssh that by adding a HostName line.
# Second account Host github-SECONDARY HostName github User git IdentityFile ~/.ssh/id_rsa_secondary那是第一个问题.
第二个是您不在遥控器中使用该主机名.
The second is you're not using that hostname in your remotes.
git remote add origin git@github:SECONDARY/testing.git ^^^^^^^^^^这是主机名部分.像这样应该是 github-SECONDARY .
That's the hostname part. It should be github-SECONDARY like so.
git remote add origin git@github-SECONDARY:SECONDARY/testing.git然后ssh将知道为 github-SECONDARY 虚拟主机使用您的特殊配置.
Then ssh will know to use your special config for the github-SECONDARY virtual host.
在"多个GitHub帐户的问答中,有一个更好的信息& SSH Config ".
更多推荐
如何在一台计算机上使用多个帐户推送git
发布评论