Today I wanted to push changes to a GitHub repository with a new account. I am still learning GitHub and thought it could be as simple as changing the git config and, but it did not work.

Here is the scenario:  

I have been using account User1 to push to GitHub repositories, and now I want to push to other repository using the User2 account. I change the and git config settings to that of User2, using config commands: 

git config --global user2
git config --global [email protected]

Now, When I try to push changes to the repo, I get this error:

Permission to <repository> denied to user1. fatal: unable to access ''. The requested URL returned 403

If you see the error message, it is still using the old user User1, even after I changed the username and email in git config, it must be caching the user credentials. What is happening here is, windows credentials manager is saving the credentials of User1 so that you don't have to enter credentials every time you are trying to push changes. If you wish to change the user, you can remove the stored credentials by going to "Credentials Manager" in windows and remove the GitHub credentials. 


The next time you try to push changes, you will be prompted to enter credentials again, now you can use the User2 credentials.