Git push 出现 permisson denied error 403

Code & Dev
由AI生成的摘要 OwO

在尝试使用 `git push -u origin main` 时,出现了权限错误,提示旧用户被拒绝访问。为了解决这个问题,作者尝试通过 `git commit --amend --reset-author` 重置提交作者,但问题依旧。最终在 Stack Overflow 找到解决方案:删除旧的凭证,成功解决了问题,节省了一个小时的时间。

在最开始尝试push:

$ git push -u origin main

结果出现:

remote: Permission to XXX/repo.git denied to Olduser.

fatal: unable to access 'https://github.com/xxx/repo.git/': The requested URL returned error: 403

因为我之前设置了local的username,但是这里却显示了旧用户被拒绝请求了,所以我以为是上一次的commit的author还是旧用户,导致验证不通过。

所以我再次尝试:

$ git commit --amend --reset-author

结果还是一样,最后在 stackoverflow 中找到了方法

1

把这个凭证删了就行,浪费我1个小时。