15

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

0

2 Answers 2

34

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

Sign up to request clarification or add additional context in comments.

1 Comment

To complete this aswer for mac users. go to Keychain > Search git > Right Click on github/gitlab/etc creditional > Delete > then username and password will be asked again and problem will be solved
6

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.

2 Comments

Credentials are correct. Somehow it's still referring to old git account user name. Between how to set SSH key ?
Or any repo-based credential exists? Set the SSH Key contains the step of "Generating a SSH Key" and "Register a SSH Key to a GitHub account".

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.