Menu

Virtual Geek

Tales from real IT system administrators world and non-production environment

Remote: Permission to UserName/repo.git denied to OtherUserName fatal: unable to access 'https://github.com/UserName/repo.git/': The requested URL returned error: 403

I was working on the one of the clients project hosted on github.com, I cloned the repo locally added few files to local repo and staged/committed project locally all was good.

git add .
git commit -m 'test'

But when tried to push the changes on remote repo on github.com. I was receiving below error. 

git push origin master
remote: Permission to UserName/repo.git denied to AnotherUserName.
fatal: unable to access 'https://github.com/UserName/repo.git/': The requested URL returned error: 403

Powershell visual studio code vscode git add git commit -message git push origin git remove permission denied the requested URL returned error 403.png

This error says that you are using wrong credential or wrong repo: the fact is when you are pushing its not asking for credentials, below are the possible reasons.

  1. Username needs to be the user, not the email
  2. Ensure you provide the proper password. If you have 2FA enabled on GitHub, you need to make sure you create an Access Token with proper access permissions and use the token as password instead.
  3. Repo format is: https://github.com/<user>/<repo>.git
  4. You have 2 different github (version control) accounts

403 means GitHub is not granting you access so one or more of the 4 above cause are the problem. In my case this issue happened due to I have one personal github account  and second received from client. Until now I was using my github account and in the past when I did push for the first time it asked my github credentials which got saved/ cached in windows credential manager, and today for the first time when I am using second account it is using username and password cached earlier for previous github account, causing access denied error.

You can solve this problem by using few methods. But below simple method helps you to solve the issue.

step 1: Go to Control Panel.
step 2: In the control panel find and go to user accounts
step 3: After that go to credential manager
step 4: Then Windows credentials
step 5: Go to Generic credentials, and search github.com, expand it
step 6: Finally delete the Github keys.

git error 403 remote access denied control panel user accounts credential manager git git hub remove generic windows credentials persistence git push origin master.png

Once cached credentials are removed, try pushing project on remote by running command git push origin master, This will prompt for GitHub login prompt, once the authentication is successful with correct username and password, command will succeed and files/folders are pushed successfully on remote github repo.

git push origin master git error 403 remote access denied another user control panel user accounts credential manager git github remove generic windows credentials persistence.png

If you don't want to remove previous users credentials from windows credentials manager another way to resolve this issue is give previous user access over new github.com repo.

Useful Article
Solved Visual studio Code make sure you configure your user.name and user.email in git
Part 1 Git version control integration in Visual Studio Code
Part 2 Git master branch source control integration in Visual Studio Code
Part 3 Git clone version control integration in Visual Studio Code

Go Back



Comment

Blog Search

Page Views

11275948

Follow me on Blogarama