如何更改Github本地仓库.git / config凭据以绕过403?

问题描述

我正在尝试从设置了其他凭据的工作PC推送到我的远程Github存储库,这就是我得到的:

remote: Permission to *** denied to ***.
fatal: unable to access 'https://github.com/***': The requested URL returned error: 403

我尝试更改.gitconfig,但没有帮助。

我怀疑VS代码以某种方式记住了工作凭证,但是我找不到它在哪里。

解决方法

找到了答案here。最后,这与重置VS代码凭据无关。

在您的repo目录下的.git/config下找到[remote "origin"]文件,将URL从以下位置更改

https://[email protected]/my-username/my-repo.git

ssh://[email protected]/my-username/my-repo.git

之后,我能够毫无问题地向上游推进。我不太清楚为什么,但是可以。