github中的多个身份

时间:2011-09-08 07:13:58

标签: git github

我有几个身份可以使用github。它们通过.ssh / config文件进行管理:

# This is the normal github account. We do not need this (it is the default),
#   but putting it here makes things more clear
Host github.com
     User           git
     HostName       github.com 
     IdentityFile   <rsa1>

# We use this fake host so that we can provide an alternative ssh keypair
Host github-2.com
     User           git
     HostName       github.com 
     IdentityFile   <rsa2>

我已经确认我已获得两个帐户的授权:

ssh -T git@github.com
Hi user1! You've successfully authenticated, but GitHub does not provide shell access.

ssh -T git@github-2.com
Hi user2! You've successfully authenticated, but GitHub does not provide shell access.

现在我转到我的仓库,尝试向遥控器推送一个新分支

git push origin origin:refs/heads/testing
error: src refspec origin does not match any.
error: failed to push some refs to 'git@github-2:user2/repo.git'

我的.git / config中的相关部分是:

[remote "origin"]
    fetch = +refs/heads/*:refs/remotes/origin/*
    url = git@github-2.com:user2/repo.git

我有这个:

$ git remote -v
origin  git@github-2.com:user2/repo.git (fetch)
origin  git@github-2.com:user2/repo.git (push)

可能出现什么问题?

1 个答案:

答案 0 :(得分:0)

我会把这个作为参考,因为我解决了我的问题:我知道怎么做,但我不知道为什么。

我做了一个新的克隆我的回购。 .git / config和我原来的一样。 在这个新副本中,我没有推送问题。魔法。