You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

在VSCode中访问GitHub时应如何选择所使用的账号?

VS Code多GitHub账号仓库访问报错说明与修复方案

VS Code内置了GitHub Authentication扩展,负责管理GitHub Personal Access Token(个人访问令牌)的创建与自动登录流程。若你同时使用多个GitHub账号,该扩展可能会为错误账号生成PAT,最终触发访问拒绝错误,常见报错信息如下:

Logon failed, use ctrl+c to cancel basic credential prompt.
remote: Permission to MyAccount/repo.git denied to OtherAccount.
fatal: unable to access 'https://github.com/MyAccount/repo.git/': Failure when receiving data from the peer

修复步骤

  • 打开VS Code扩展面板,找到GitHub Authentication扩展,先禁用再重新启用
  • 按下Ctrl+Shift+P(Mac系统为Cmd+Shift+P)调出命令面板,输入GitHub: Sign Out,将所有已登录的GitHub账号全部登出
  • 重新执行Git拉取/推送操作,在弹出的GitHub授权页面选择目标仓库所属的对应账号完成授权即可
  • 若问题仍未解决,可手动清除系统存储的GitHub相关凭据:
    • Windows系统:打开「凭据管理器」→「Windows凭据」,删除所有前缀为git:https://github.com的条目
    • Mac系统:打开「钥匙串访问」,搜索github,删除所有关联的互联网密码条目
    • Linux系统:执行git config --global --unset credential.helper清除全局凭据配置,再重新操作触发授权流程

内容的提问来源于stack exchange,提问作者Dennis

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.10.07 13:00:01