【问题标题】:remote: Permission to repository denied. URL returned error: 403远程:拒绝存储库的权限。网址返回错误:403
【发布时间】:2022-06-21 07:56:38
【问题描述】:

可能是一个重复的问题,但似乎没有可用的解决方案有效。可能是 Github 自 2021 年 8 月 13 日起更改了对密码的支持。

我尝试了以下方法:

  1. 检查了用户名和密码。
  2. 创建了个人访问令牌。
  3. 重新检查 .git/config 文件中的原始 URL。

错误信息:

Username for 'https://github.com': gandharvsuri
Password for 'https://gandharvsuri@github.com': 
remote: Permission to gandharvsuri/gandharvsuri.github.io.git denied to gandharvsuri.
fatal: unable to access 'https://github.com/gandharvsuri/gandharvsuri.github.io.git/': The requested URL returned error: 403

【问题讨论】:

    标签: git github


    【解决方案1】:

    首先你需要生成新的令牌

    我的账户-设置-开发者设置-个人访问令牌-生成新令牌

    生成令牌后

    git remote set-url origin https://<token>@github.com/<username>/<repo>
    

    【讨论】:

    • 我试过这个,但我仍然收到错误。现在它也没有要求我的用户名和密码,而是直接给我权限被拒绝错误(403)。
    【解决方案2】:

    我在 https 连接时遇到了同样的错误。当我使用 ssh 克隆 repo 时,问题已解决。

    我跟随this link生成SSH密钥对。

    在上面的链接上完成该步骤后:

    ssh -T git@github.com
    

    您已准备好使用 SSH。

    现在我使用 VSCode 来克隆我的 repo。您也可以关注任何其他工具或终端。

    打开 VSCode 后,点击 Clone Git Repository...

    之后您可以看到以下内容:

    现在,您需要输入您的存储库的 SSH 连接:

    只需复制并粘贴该链接,您的 repo 就会使用 SSH 协议进行克隆。因此,您可以使用 VSCode 或 Github Desktop 来推送或拉取或处理任何其他无需 https(身份验证令牌)的请求。

    【讨论】:

      猜你喜欢
      • 2019-11-05
      • 2023-03-30
      • 2016-04-21
      • 1970-01-01
      • 2014-02-05
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多