1

So, I am attempting to push a repository to Github using Git bash. The thing is, it still thinks that I am using a username that I was previously using. However, I changed this username and I checked to be sure with the following commands:

git config user.name
"CorrectName"
git config user.email
"CorrectEmail@correctdomain"
git config --global user.name
"CorrectName
git config --global user.email
"CorrectEmail@correctdomain"

However, Github is still using my previous user name to push the repo. This is evident by the command to push:

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

What can I do in order to successfully push my repo?

kevin29
  • 91
  • 1
  • 9

3 Answers3

0

Try removing you remote and re additing it.

git remote rm origin
git remote add origin <your origin url>
Vinit Sarvade
  • 750
  • 6
  • 14
0

Remove your user settings:

Name:

$ git config --global --unset user.name

Email:

$ git config --global --unset user.email

or all your global settings:

$ git config --global --unset-all

Then set your username in git.

To check who you are:

$ git config --list
Abraham
  • 8,525
  • 5
  • 47
  • 53
  • @kevin29 You can visit this [link](https://stackoverflow.com/questions/23740734/logout-and-login-as-another-user-git-bash) to see how to log out from git and then login again, I think that's the easy way to do it! – Abraham Dec 29 '17 at 18:42
  • That is what I already tried in the original post. Any other ideas? – kevin29 Jan 02 '18 at 14:11
  • If you remove completely from your computer your git configuration and reconfigure again, it should always work. – Abraham Jan 28 '18 at 07:45
0

Ok, I got it to work. Someone helped me and advised me to run a git config --local credential.helper "" command in my project directory and also a git config --global --unset credential.helper command. It seems like the credentials were still being stored somehow, but git asked for a username and password before pushing after unsetting the credential helper and the push was successful.

kevin29
  • 91
  • 1
  • 9