git - 无法更改 Git 帐户

标签 git github window

我尝试推送到我的存储库,但出现以下错误:

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并重新安装,但都不行。

Enter image description here

全局配置文件

Enter image description here

我该如何解决这个问题?

最佳答案

这与你的user.name无关/user.email设置:那些用于提交中的作者身份。当您推送到存储库时,它们用于身份验证。

如果 Git 询问您的 GitHub(新)用户名/密码,这意味着 Git for Windows正在使用名为“manager”的 Git 凭证助手(执行 git config credential.helper 以确认)

含义:它正在缓存您的旧凭据并自动重新使用它们。

在这种情况下,转到 Windows 开始菜单 (Windows start),键入“凭据”并选择 Windows 工具“Windows Credential Manager”。
enter image description here
在其中,您会找到一个条目 git.https://github.com ,您可以对其进行编辑,并且可以在其中输入新的 GitHub 用户名/密码。 Enter new credentials

然后再次尝试推送。


使用更新的 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/

相关文章:

git - 有没有办法从 GitHub 下载完整的历史记录?

git - 使用git扫描源代码生成待办事项列表等

windows - 操作系统重置后 "Not a git repository"

git - 如何构建我的解决方案的早期版本?

ios - 在 FSCalendar 中添加自定义假期

javascript - 如果我添加此 if 语句,为什么我的网站在移动设备上不显示任何内容?

git - 有没有办法在无缝提交 py 文件而不是 ipynb 时一起使用 Git 和 Jupyter 笔记本?

git - 永久删除 Git 中的单个旧提交

c++ - SDL2 多窗口焦点

wpf - 在 WPF 中为 ToolWindow 添加图标