我尝试推送到我的存储库,但出现以下错误:
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
之前,我使用的用户名是edgarphan
,但我已经将其更改为PhanVanLinh
,但它仍然保留edgarphan
。
我尝试过删除项目并重新克隆,卸载Git并重新安装,但都不行。
全局配置文件
我该如何解决这个问题?
最佳答案
这与你的user.name
无关/user.email
设置:那些用于提交中的作者身份。当您推送到存储库时,它们不用于身份验证。
如果 Git 不询问您的 GitHub(新)用户名/密码,这意味着 Git for Windows正在使用名为“manager”的 Git 凭证助手(执行 git config credential.helper
以确认)
含义:它正在缓存您的旧凭据并自动重新使用它们。
在这种情况下,转到 Windows 开始菜单 (),键入“凭据”并选择 Windows 工具“Windows Credential Manager”。
在其中,您会找到一个条目 git.https://github.com
,您可以对其进行编辑,并且可以在其中输入新的 GitHub 用户名/密码。
然后再次尝试推送。
使用更新的 Git 版本(2.32+,2021 年第 2 季度),假设 <C:\path\to\git>\usr\bin
和 <C:\path\to\git>\mingw64\libexec\git-core
在你的%PATH%
,您可以在命令行中执行相同的删除操作:
printf "protocol=https\nhost=github.com\nusername=xxx"| git-credential-manager-core erase
关于git - 无法更改 Git 帐户,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46629838/