Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Unable to change Git account

Tags:

git

github

window

I tried to push to my repository, but I got the error below:

git push origin master remote: Permission to PhanVanLinh/phanvanlinh.github.io.git denied to edgarphan. fatal: unable to access 'https://github.com/PhanVanLinh/phanvanlinh.github.io.git/': The requested URL returned error: 403 

Before, I was using username edgarphan, but I have already changed it to PhanVanLinh, but it still keeps edgarphan.

I have tried to delete the project and clone again, uninstall Git and reinstall, but it won't work.

Enter image description here

Global configuration file

Enter image description here

How can I fix this issue?

like image 690
Linh Avatar asked Oct 08 '17 09:10

Linh


People also ask

How do I switch accounts in Git bash?

Go to: Control Panel -> User Accounts -> Manage your credentials -> Windows Credentials -> under Generic Credentials there are some credentials related to Github, click on them and click "Remove". @Fre1234 Great!

How do I reset my Git login credentials?

Go to Control Panel > User Accounts > Credential Manager > Windows Credentials. You will see Git credentials in the list (e.g. git:https://). Click on it, update the password, and execute git pull/push command from your Git bash and it won't throw any more error messages.


1 Answers

This has nothing to do with your user.name/user.email settings: those are for authorship in a commit. They are not used for authentication when you push to a repo.

If Git does not ask you for your GitHub (new) username/password, that means Git for Windows is using a Git credential helper called "manager" (do a git config credential.helper to confirm it)

Meaning: it is caching your old credentials and is reusing them automatically.

In that case, go to the Windows start menu (Windows start), type "credential" and select the Windows tool "Windows Credential Manager".
enter image description here
In it, you will find an entry git.https://github.com, which you can edit, and where you can enter your new GitHub username/password. Enter new credentials

Then try and push again.


With more recent Git version (2.32+, Q2 2021), assuming <C:\path\to\git>\usr\bin and <C:\path\to\git>\mingw64\libexec\git-core are in your %PATH%, you can do the same removal in command-line:

printf "protocol=https\nhost=github.com\nusername=xxx"| git-credential-manager-core erase 
like image 80
VonC Avatar answered Sep 19 '22 15:09

VonC