cool1 cool1 - 4 months ago 51
Git Question

fatal: unable to access 'https://github.com/SOME_NAME/SOME_PROJECT.git/': The requested URL returned error: 403

git push
remote: Permission to newGithubAccount/newGithubAccountProject.git denied to myOldGithubAccount.
fatal: unable to access 'https://github.com/newGithubAccount/newGithubAccountProject.git/': The requested URL returned error: 403


I got the 403 error, I know it's that incorrect access was found, and the error message clearly shows me why:
Because my git push was using my previous github account's credentials, however, I've updated my git global config and generated new
.ssh/id_rsa
and added the ssh key into my new github account.
But still this error persists, I've searched extensively on this site and on Github.help page, but still no luck, please help.

I think I need to somehow completely clear my cache for the previous github account or delete it, then I could access github with my new account.
Or else ways, please advise!
Thanks a lot!

Answer

The previous remote is configured to use the HTTP protocol. You can use the set-url remote command to update your remote to use the SSH based protocol.

git remote set-url origin git@github.com:newGithubAccount/newGithubAccountProject.git

https://help.github.com/articles/changing-a-remote-s-url/