【问题标题】:problem in pushing to github推送到github的问题
【发布时间】:2011-08-20 02:28:02
【问题描述】:

我在 github 上创建了一个名为 pygame 的存储库。创建了一个克隆并添加了文件并提交了。但是当我尝试推送时,我收到以下错误:

git push -u origin master

error: The requested URL returned error: 403 while accessing https://github.com/amalapk/pygame/info/refs

fatal: HTTP request failed

我可以 ssh 到 git@github.com 并收到我成功登录的通知,但无法推送到我的存储库。

【问题讨论】:

标签: github


【解决方案1】:

我最近在设置我的 github 项目的新克隆时遇到了这个问题。

您需要在项目的 URL 中包含您的用户名,格式为

https://user@github.com/project/...

比如我的测试github提供的URL是这样的:

https://github.com/jdblair/test.git

如果我像这样添加我的用户名,那么我可以毫无问题地从 github 推送和拉取:

https://jdblair@github.com/jdblair/test.git

使用包含从克隆项目时开始的用户名的 URL 是最简单的。

您可以像这样更改现有项目的 URL:

git remote set-url origin https://user@github.com/project/foo/bar.git

您可以根据需要使用 ssh 身份验证,但这是一个单独的设置过程。

【讨论】:

  • 这为我解决了这个问题(我有 git 1.7.1,由于它不在我管理的服务器上,因此无法轻松升级)
【解决方案2】:

Github 现在要求我们使用 git 1.7.10 或更高版本:

https://help.github.com/articles/error-the-requested-url-returned-error-403

【讨论】:

  • 正是我需要的。人们应该在尝试其他解决方案之前检查他们的 git 版本。谢谢!
【解决方案3】:

GitHub Remote page 提到了回购的读/写地址:

确保你的克隆地址是这样的:

https://github.com/username/yourRepo.git

你已经定义了:

git config --global user.name "Firstname Lastname"
git config --global user.email "your_email@youremail.com"

如果你使用 git 地址(不带 ssh),你还需要:

git config --global github.user username
git config --global github.token 0123456789yourf0123456789token # no longer needed

(您的令牌来自“帐户设置”>点击“帐户管理员”。)

2013 年更新:您仍然可以生成令牌(请参阅“Creating an access token for command-line use”),但您可以将其用作 https 网址的密码。

实际上,如果您激活2FA (two-factor authentication) mechanism on GitHub,您将需要一个用于您的https url的令牌(因为您的常规密码会触发第二步验证)。
见“Configure Git clients, like GitHub for Windows, to not ask for authentication

在“Which remote URL should I use?”查看更多信息。

【讨论】:

  • Github 不再使用令牌。寻找其他解决方案。
【解决方案4】:

一切尽在remote

将您当前的遥控器从 https://github.com/amalapk/pygame.git 更改为 git@github.com:amalapk/pygame.git 并享受。

为此...(假设您当前的遥控器名为origin

git remote set-url origin git@github.com:amalapk/pygame.git

【讨论】:

  • https 协议是只读的。但是git 协议在可读写的 SSH 上被过度使用了……我认为
【解决方案5】:

在我的情况下,消除此类错误消息是通过以下方式解决的: Person 只是作为合作者添加到 github 存储库中。 就是这样 - 错误神奇地消失了。

【讨论】:

    【解决方案6】:

    从服务器提交到 github 这在终端或 git bash 中对我有用

    要创建一个远程到 github.com 试试:

    git remote add origin https://put your username here@github.com/put your git username here/put your repository name here
    

    要更换遥控器,只需:

    git remote set-url origin https://put your username here@github.com/put your git username here/the name of your repository here
    

    【讨论】:

      【解决方案7】:

      请按照http://help.github.com/create-a-repo/上的说明操作

      您已使用公共 只读 url 克隆了您的存储库。

      实时调频

      【讨论】:

      • “下一步”页面上提供的 URL 确实与 OP 提供的 URL 非常相似。我的猜测是,他们确实已经成为 Ze 评论中报告的问题的牺牲品:github 推荐 https:// 网址,但他们在旧版本的 git 上抛出 403。
      猜你喜欢
      • 1970-01-01
      • 2017-12-06
      • 1970-01-01
      • 2018-10-14
      • 2022-01-19
      • 2017-04-18
      • 2020-02-05
      • 1970-01-01
      • 2016-04-26
      相关资源
      最近更新 更多