1

How can I change my github account?

When I type git push on the terminal, I receive this message:

remote: Permission to myAccount/myProject.git denied to mySecondAccount. fatal: unable to access 'https://github.com/myAccount/myProject.git/': The requested URL returned error: 403

I already used git config --global user.name and git config --global user.email.

But there is no effect.

stevenferrer
  • 2,504
  • 1
  • 22
  • 33
kyun
  • 9,710
  • 9
  • 31
  • 66
  • 1
    Maybe you have local git config options in your repository (where the global option wouldn't be used) – scrowler Oct 16 '17 at 02:51
  • try `git config user.name` and `git config user.email` to see if you have a local git config for that repository. – stevenferrer Oct 16 '17 at 03:47
  • @srxf When I type `git config user.name` and `git config user.email`, the output is `myAccountName` and `myAccountEmail`. But still occurred error 403. – kyun Oct 16 '17 at 04:14
  • do you use ssh or you enter your username and password manually? – stevenferrer Oct 16 '17 at 04:23

2 Answers2

1

Found this on web

"remote: Permission to myAccount/myProject.git denied to mySecondAccount. fatal: unable to access 'https://github.com/myAccount/myProject.git/': The requested URL returned error: 403"

This error means the key you are pushing with is attached to another repository as a deploy key, and does not have access to the repository you are trying to push to.

To fix this, remove the deploy key from the repository, and add the key to your user account instead.

If the key you are using is intended to be a deploy key, check out our guide on deploy keys for more details.

https://help.github.com/articles/error-permission-to-user-repo-denied-to-user-other-repo/

Nisal Edu
  • 7,237
  • 4
  • 28
  • 34
1

First, user.name and user.email have nothing to do with the credentials (username/password) used to authenticate when pushing to GitHub with an https URL.

When you use https, there is a chance your credentials (again: username/password) were cached by a credential helper: type git config credential.helper to confirm it.

If that is the case, you need to delete the entry for https://github.com and push again: you will be asked for your new credentials.
See here for an example when using Git for Windows. Depending on your OS, that might differ, but the idea remains the same.

VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250