In this post, we will look at what happens when you are trying to push from Visual Studio Code to a GitHub repo and the wrong user is being passed, thereby giving you the error that you do not have permission to post to this repository.
The remote branch I am trying to push to is on my account carldesouzacom:
And in Git in Windows, it thinks I am using a different user.
In VS Code, I have signed in using the account I want:
But when I push, it thinks I am a different user, in this case, carldesouza – “e: Permission to carldesouzacom/my-linter-test.git denied to carldesouza.
fatal: unable to access ‘https://github.com/carldesouzacom/my-linter-test/’: The requested URL returned error: 403”:
In order to resolve this, go into Windows and go to Control Panel, then search for the Credential Manager. Then delete the GitHub credentials. You may notice that some of these credentials are in fact using the GitHub user you do not want to authenticate with.
Once removed, run the command to push to your GitHub repo, e.g.
git push –set-upstream my-linter-test main
You will be prompted to log in:
And click Allow:
And grant access.
You will now be able to push to GitHub.