Sandra
Sandra

Reputation: 86

Github: How can I push to an organization's repo that I don't have permissions to clone

I have two github accounts. I have created SSH keys for both, and configured them accordingly. I know that my config works because I can push to both accounts for my personal repos fine. Example config

Host github.com
etc
IdentityFile: id_rsa

Host github-second
etc
IdentityFile: id_rsa_second

To add remote for my normal account, I use git remote add origin [email protected]:account/repo.git To add remote for the second account, I use git remote add origin git@github-second:second-account/other-repo.git

I am now a member of an organization with my second account. The url for the repo of interest looks like github.com/organization/org-repo vs github.com/second-account/org-repo. I have tried to add the org repo using: git remote add origin git@github-second:organization/org-repo and I indeed got the repo files on my local machine. However, I cannot push to the org repo. Error:

fatal: Could not read from remote repository.
Please make sure you have the correct access rights and the repository exists.```

I have contacted the organization and they said that I have full write access. 
I am not sure what else to try.

Upvotes: 3

Views: 1085

Answers (1)

Sandra
Sandra

Reputation: 86

I fixed it by:

  1. Re-adding the id_rsa_second
  2. Check ssh -T git@github-second and make sure it is pointed to second-account
  3. git remote add origin git@github-second:second-account/org-repo.git
  4. git remote add upstream git@github-second:org-account/org-repo.git
  5. Push to upstream. Hopefully, this helps someone else.

Upvotes: 1

Related Questions