1

I have several identities to work with github. They are managed via the .ssh/config file:

# 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>

I have verified that I am authorized with both accounts:

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.

Now I go to my repo, and try to push to the remote a new branch

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'

The relevant section in my .git/config is:

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

And I have this:

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

What could be going wrong?

blueFast
  • 41,341
  • 63
  • 198
  • 344
  • Did you check http://stackoverflow.com/questions/827351/push-origin-master-error-on-new-repository and http://stackoverflow.com/questions/959477/error-when-git-push-to-github ? – CharlesB Sep 08 '11 at 07:27

1 Answers1

0

I will put this here for reference, since I solved my issue: I know how, but I do not really know why.

I did a new clone of my repo. The .git/config was the same as my original one. In this fresh copy, I have no push issues. Magic.

blueFast
  • 41,341
  • 63
  • 198
  • 344
  • `git push origin origin:refs/heads/testing error: src refspec origin does not match any.` This error literally means "You asked me to push the ref 'origin' to the ref 'testing' on the remote 'origin' but I couldn't find that ref". `origin:` is telling it to find a local branch named "origin", which it sounds like you don't have. – Tekkub Sep 09 '11 at 02:35