Error 403 when git push (multiple github accounts on the same mac)

gitgithubmac-osx

I have two GitHub accounts on the same Mac. And have credential-osxkeychain installed. It works fine with my first GitHub account. But, how can I add the second account into the keychain access? If it is not possible, how can I 'logout' my first account?

P.S. I can't use SSH key on my network.

P.S. I have already set git config user.name & git config user.email at the second repo. Error 403 show up when I git push. Github didn't ask me for the password of the second account. I think git is pushing the repo with the wrong account & password.

Best Answer

If you're trying to use SSH authentication, Github is probably seeing the first ssh key and associating it with the first account, then denying that account access to the second account's repos. I suggest switching one or both of the accounts to http based access.

For example, over SSH my repo URL would be: git@github.com:opie4624/repoA.git while the HTTP equivalent would be: https://github.com/opie4624/repoA.git.

When pushing or pulling with the HTTP url, git will prompt for the username and password allowing you to specify which of the two Github accounts to use. That also saves you from mucking about with ssh keys.

Hope this helps!

Related Topic