One month ago I configured two github accounts on my mac: one account for work and another for personal use. I've been using both for a month without problems. In the day commiting/pushing/etc to repos from work. At night, commiting/pushing/etc in a couple of personal repos. Suddenly, today I was unable to push some changes in one of my personal account, the error is:
git push --set-upstream origin <branch>
ERROR: Permission to <repo>.git denied to <work-account>.
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
I don't know why git push command is trying to push using my work account!?!?!?
My previous changes and push in this repo were 7 days ago with my personal account (without issues). I did not change anything in my config (ssh, .git/config files, etc.)!
I tried this in the directory of the repo:
git config user.email
git config user.name
Email is my personal email, so this is correct.
Why is git using my work account? Even if the git config
command display my personal account?
Also, this was working some days ago ...
Note 2:
- I have both accounts defined in ~/.ssh directory: id_rsa, id_rsa.pub, id_rsa_, id_rsa_.pub.
- ~/.ssh/config is also defined:
Host github.com
Hostname github.com
User git
AddKeysToAgent yes
UseKeychain yes
IdentityFile ~/.ssh/id_rsa
Host <githubpersonal>
Hostname github.com
User git
IdentityFile ~/.ssh/id_rsa_<personal_account>
- the remote origin of the repo I think it's well defined:
[remote "origin"]
url = git@<githubpersonal>:<personal_account>/<repo>.git
fetch = +refs/heads/*:refs/remotes/origin/*
- if I run
git remote -v
I get:
origin git@<githubpersonal>:<personal_account>/<repo>.git (fetch)
origin git@<githubpersonal>:<personal_account>/<repo>.git (push)
I don't know why is not working anymore ...