Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Git returning Error 403 while pushing the code [duplicate]

Tags:

git

github

Everything was working fine, until I create a new GitHub account. When I try to push the code for first time to github server with new account, following error is occurring:

remote: Permission to NEW_USER/NEW_REPO.git denied to OLD_USER.
fatal: unable to access 'https://github.com/NEW_USER/NEW_REPO/': The requested URL returned error: 403

Tried to reset remote url using:

$git remote set-url origin https://[email protected]/user/repo.git ... but not working.

Got one solution here, but for Mac OS. Any ideas how to resolve this. Using git bash version 2.16.1.windows.4.

Thanks

like image 996
calvin.mk Avatar asked Jul 08 '18 12:07

calvin.mk


People also ask

How do I fix the requested URL returned error 403 in Git repository?

The first is relatively simple to resolve and simply involves checking to ensure your GitHub password is correct. If the error persists, it is likely that you have to use a different HTTPS address in your Git client. For this error, you will not even be prompted to enter a password, making it simpler to diagnose.

What causes a 403 response?

Causes of 403 Forbidden Often, HTTP 403 forbidden errors are caused by an access misconfiguration on the client-side, which means you can usually resolve the issue yourself. A common cause of these errors is the file or folder permission settings, which control who can read, write, and execute the file or folder.

What is the 403 error code?

The HTTP 403 Forbidden response status code indicates that the server understands the request but refuses to authorize it. This status is similar to 401 , but for the 403 Forbidden status code re-authenticating makes no difference.


2 Answers

You may check for the Git Credentials you are using, and change that with your new account.

As the top answer from the question you mentioned says, using a SSH way by

$ git remote set-url origin [email protected]:new_user/new_repo.git

(and set the SSH Key) instead of HTTPS way is also a workaround.

like image 193
Geno Chen Avatar answered Oct 24 '22 19:10

Geno Chen


This happens when two git accounts are being used on same machine. On Windows 7 you need to remove git Credentials from Windows vault.

  • go to Control Panel -> User Accounts -> Manage your credentials.
  • Under Generic Credentials delete entries for github credentials.
  • Try to push code and this time it will prompt you for correct username and password again.

enter image description here

like image 30
codeworks elegant Avatar answered Oct 24 '22 20:10

codeworks elegant