【问题标题】:The requested URL returned error: 403 Forbidden while accessing github.com请求的 URL 返回错误:403 Forbidden while access github.com
【发布时间】:2016-10-25 05:20:42
【问题描述】:

所以,我在另一台机器上设置了一个 repo。我已经提交并推送了文件,他们在 github.com 上查看得很好。现在,我在另一台机器上运行了git init,我正在尝试拉动。

# git remote set-url origin git@github.com:me/someproj.git
fatal: No such remote 'origin'

# git remote add origin https://github.com/me/someproj.git

# git pull
error: The requested URL returned error: 403 Forbidden while accessing https://github.com/me/someproj.git/info/refs

fatal: HTTP request failed

# git remote -v
origin  https://github.com/me/someproj.git (fetch)
origin  https://github.com/me/someproj.git (push)

# git pull origin
error: The requested URL returned error: 403 Forbidden while accessing https://github.com/me/someproj.git/info/refs

fatal: HTTP request failed

【问题讨论】:

  • 请提供更多信息 - 您在那台机器上使用的是哪个 git 版本?你设置了用户名和密码吗?您是在防火墙后面还是在使用代理?
  • git 版本 1.7.1 并且不,我不支持代理,我知道。我不确定我是否设置了用户/通行证。
  • 这可能是您的问题,请使用git config --global user.name your_username 设置它并对您的密码执行相同操作。
  • @ShmulikKlein user.name 与身份验证无关。

标签: git github


【解决方案1】:

如果您在同一台计算机上使用两个帐户,则会抛出此错误。

在 Windows 10 中 控制面板 -> 用户帐户 -> 管理您的凭据。 移除 github 账号。

【讨论】:

    【解决方案2】:

    对于那些无法通过删除凭据或更改 url 来解决问题的人。

    我强烈建议检查您是否有权推送到 repo。为确保这一点,请请求 repo 的管理员在 repo 设置的“Manage Access”部分中授予您WRITE 权限。 希望这对你有用。

    【讨论】:

      【解决方案3】:

      您可以尝试git remote -v 命令检查远程repo URL 是否正常。 如果不是,你应该试试

      git remote set-url origin repo-url
      

      修正错别字

      【讨论】:

        【解决方案4】:

        当您尝试从浏览器访问https://github.com/me/someproj.git/info/refs 时,您会注意到以下与 403 状态代码相关的消息:

        请升级您的 git 客户端。 GitHub.com 不再支持 git over 哑-http: https://github.com/blog/809-git-dumb-http-transport-to-be-turned-off-in-90-days

        如果您使用的是 1.6.6 之前的 git,请尝试更新它或更好地使用 SSH 协议。

        还可以使用git config --global user.name 和git config --global user.password 检查您的设置。

        【讨论】:

          【解决方案5】:

          您需要检查您在成功推送到 GitHub 的计算机上使用的凭据(用户名/密码),并在新的本地存储库中重新使用这些凭据。

          特别检查所使用的 url 类型:ssh (git@github.com:me/someproj.git) 或 https (https://github.com/me/someproj.git)。
          还要检查您是否是该 GitHub 帐户和存储库的 using 2FA (Two-Factor Authentication)。

          您可以嵌入right username in your url::

          cd /path/to/new/local/repo
          git remote add origin https://me@github.com/me/someproj.git
          

          【讨论】:

            猜你喜欢
            • 2013-11-12
            • 1970-01-01
            • 2020-03-12
            • 1970-01-01
            • 2022-10-24
            • 2016-12-05
            • 2022-07-31
            • 1970-01-01
            相关资源
            最近更新 更多