首页 > 解决方案 > 远程:推送到 github 时权限被拒绝

问题描述

我有两个用户名 samwelnm2022 和 mchomvus4 的 github 帐户,我有工作要推送到用户名 mchomvus4 但是当我尝试从 git 推送时,我收到一条错误消息

remote: Permission to myRepositoryname.git denied to samwelnm2022.
fatal: unable to access 'https://github.com/myRepositoryname.git/': The requested URL 

returned error: 403

我尝试使用 github Desktop 推动工作,并且工作正常

任何可以帮助我的人请

标签: gitgithub

解决方案


使用错误的用户名意味着凭证缓存 ( git config credential.helper) 已缓存与 samwelnm2022 关联的凭证github.com

如果您需要使用其他帐户进行一次推送,请尝试:

git push https://mchomvus4@github.com/<me>/<myRepo> master

这将强制为该特定推送使用不同的 GitHub 用户帐户。


推荐阅读