Unable to change Git account

 ̄綄美尐妖づ 提交于 2019-11-26 02:58:04

问题


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.

Global configuration file

How can I fix this issue?


回答1:


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 (), type "credential" and select the Windows tool "Windows Credential Manager".

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.

Then try and push again.




回答2:


Try to find out the Git configuration file. For a Windows machine it probably located at

C:\Users\<user_name>\.gitconfig

This command may open up the configuration file too. Then you can just edit and save:

git config --global -e

And after setting the configuration, do:

cd /path/to/new/local/repo
git remote add origin https://github.com/PhanVanLinh/phanvanlinh.github.io.git
git push -u origin master


来源:https://stackoverflow.com/questions/46629838/unable-to-change-git-account

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!