0

git config shows correct user name and email and yet I cannot ever git push to my own repo on GitHub. It always says some old username that was used

git config user.name mqshaikh8

git config user.email mqshaikh8@gmail.com

git push origin master

remote: Permission to mqshaikh8/amigo.git denied to kshaikh99. fatal: unable to access 'https://github.com/mqshaikh8/amigo.git/': The requested URL returned error: 403

git remote --v origin https://github.com/mqshaikh8/amigo.git (fetch) origin https://github.com/mqshaikh8/amigo.git (push)

parlad
  • 1,143
  • 4
  • 23
  • 42
  • Are you using `git bash`/`git for windows` by any chance? – Vivick Jan 06 '19 at 13:22
  • Yes I am using git for windows – Parvez Mohammed Jan 06 '19 at 13:23
  • The `user.name` and `user.email` settings have nothing to do with authentication. They're used for creating commits, not for talking to remotes. You need to [provide your HTTPS credentials or an SSH key](https://help.github.com/articles/set-up-git/#next-steps-authenticating-with-github-from-git). – ChrisGPT was on strike Jan 06 '19 at 13:39
  • in any case, you should remove the old unused user config first. Then add new auth, https://stackoverflow.com/questions/6243407/delete-username-from-a-git-repository – parlad Jan 06 '19 at 13:44
  • Does this answer your question? [Remove credentials from Git](https://stackoverflow.com/questions/15381198/remove-credentials-from-git) – Daemon Painter Jul 23 '20 at 07:05

2 Answers2

0

It happened to me quite a bit, mostly after a typo in my password and couldn't ever type a password again.

Usually installing git bash again over the old installation fixes the problem.

If you're using the default settings/windows credentials the please see this github issue on git for desktop to help you on this matter.

This SO post on how to remove git credentials might also help.

Vivick
  • 3,434
  • 2
  • 12
  • 25
0

Finally what worked is the following:

I was logged into windows as kshaikh99. Since git integrated with windows credential manager, it had cached the kshaikh99 username and password and regardless of what's in git config user.name and user.email, it always used that credential to authenticate and that's why it was failing.

I just signed off and signed into windows as mqshaikh8. Then when I tried to git push origin master, I got a windows credential dialog box to enter my mqshaikh8 username and password. I entered that and it works with no issues.

  • While this is "a" solution, is by far not a general or practiceable one. For instance, I never use the same password for my PCs and any kind of web-app accounts, so that would not work. The issue, as you correctly state, is in the windows Credential Manager, and that would be by far a more general answer. – Daemon Painter Jul 23 '20 at 07:05