提交到Git返回错误代码403致命错误:HTTP请求失败

819

我能够通过HTTPS认证克隆该存储库的一个副本。我已经提交了一些更改并希望将它们推送回GitHub服务器。在Windows 7 x64上使用Cygwin。

C:\cygwin\home\XPherior\Code\lunch_call>git push
Password:
error: The requested URL returned error: 403 while accessing https://MichaelDrog
alis@github.com/derekerdmann/lunch_call.git/info/refs

fatal: HTTP request failed

同时设置为详细模式。我仍然感到相当困惑。

C:\cygwin\home\XPherior\Code\lunch_call>set GIT_CURL_VERBOSE=1

C:\cygwin\home\XPherior\Code\lunch_call>git push
Password:
* Couldn't find host github.com in the _netrc file; using defaults
* About to connect() to github.com port 443 (#0)
*   Trying 207.97.227.239... * 0x23cb740 is at send pipe head!
* Connected to github.com (207.97.227.239) port 443 (#0)
* successfully set certificate verify locations:
*   CAfile: C:\Program Files (x86)\Git/bin/curl-ca-bundle.crt
  CApath: none
* SSL connection using AES256-SHA
* Server certificate:
*        subject: 2.5.4.15=Private Organization; 1.3.6.1.4.1.311.60.2.1.3=US; 1.
3.6.1.4.1.311.60.2.1.2=California; serialNumber=C3268102; C=US; ST=California; L
=San Francisco; O=GitHub, Inc.; CN=github.com
*        start date: 2011-05-27 00:00:00 GMT
*        expire date: 2013-07-29 12:00:00 GMT
*        subjectAltName: github.com matched
*        issuer: C=US; O=DigiCert Inc; OU=www.digicert.com; CN=DigiCert High Ass
urance EV CA-1
*        SSL certificate verify ok.
> GET /derekerdmann/lunch_call.git/info/refs?service=git-receive-pack HTTP/1.1
User-Agent: git/1.7.4.3282.g844cb
Host: github.com
Accept: */*
Pragma: no-cache

< HTTP/1.1 401 Authorization Required
< Server: nginx/1.0.4
< Date: Thu, 15 Sep 2011 22:44:41 GMT
< Content-Type: text/plain
< Connection: keep-alive
< Content-Length: 55
< WWW-Authenticate: Basic realm="GitHub"
<
* Ignoring the response-body
* Expire cleared
* Connection #0 to host github.com left intact
* Issue another request to this URL: 'https://MichaelDrogalis@github.com/dereker
dmann/lunch_call.git/info/refs?service=git-receive-pack'
* Couldn't find host github.com in the _netrc file; using defaults
* Re-using existing connection! (#0) with host github.com
* Connected to github.com (207.97.227.239) port 443 (#0)
* 0x23cb740 is at send pipe head!
* Server auth using Basic with user 'MichaelDrogalis'
> GET /derekerdmann/lunch_call.git/info/refs?service=git-receive-pack HTTP/1.1
Authorization: Basic XXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
User-Agent: git/1.7.4.3282.g844cb
Host: github.com
Accept: */*
Pragma: no-cache

< HTTP/1.1 401 Authorization Required
< Server: nginx/1.0.4
< Date: Thu, 15 Sep 2011 22:44:41 GMT
< Content-Type: text/plain
< Connection: keep-alive
< Content-Length: 55
* Authentication problem. Ignoring this.
< WWW-Authenticate: Basic realm="GitHub"
* The requested URL returned error: 401
* Closing connection #0
* Couldn't find host github.com in the _netrc file; using defaults
* About to connect() to github.com port 443 (#0)
*   Trying 207.97.227.239... * 0x23cb740 is at send pipe head!
* Connected to github.com (207.97.227.239) port 443 (#0)
* successfully set certificate verify locations:
*   CAfile: C:\Program Files (x86)\Git/bin/curl-ca-bundle.crt
  CApath: none
* SSL re-using session ID
* SSL connection using AES256-SHA
* old SSL session ID is stale, removing
* Server certificate:
*        subject: 2.5.4.15=Private Organization; 1.3.6.1.4.1.311.60.2.1.3=US; 1.
3.6.1.4.1.311.60.2.1.2=California; serialNumber=C3268102; C=US; ST=California; L
=San Francisco; O=GitHub, Inc.; CN=github.com
*        start date: 2011-05-27 00:00:00 GMT
*        expire date: 2013-07-29 12:00:00 GMT
*        subjectAltName: github.com matched
*        issuer: C=US; O=DigiCert Inc; OU=www.digicert.com; CN=DigiCert High Ass
urance EV CA-1
*        SSL certificate verify ok.
* Server auth using Basic with user 'MichaelDrogalis'
> GET /derekerdmann/lunch_call.git/info/refs HTTP/1.1
Authorization: Basic xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
User-Agent: git/1.7.4.3282.g844cb
Host: github.com
Accept: */*
Pragma: no-cache

* The requested URL returned error: 403
* Expire cleared
* Closing connection #0
error: The requested URL returned error: 403 while accessing https://MichaelDrog
alis@github.com/derekerdmann/lunch_call.git/info/refs

fatal: HTTP request failed

以下是我所拥有的Git和Curl版本:

C:\Users\XPherior>git --version
git version 1.7.4.msysgit.0

C:\Users\XPherior>curl --version
curl 7.21.7 (amd64-pc-win32) libcurl/7.21.7 OpenSSL/0.9.8r zlib/1.2.5
Protocols: dict file ftp ftps gopher http https imap imaps ldap pop3 pop3s rtsp
smtp smtps telnet tftp
Features: AsynchDNS GSS-Negotiate Largefile NTLM SSL SSPI libz

4
看一下这条评论,应该发布为答案。我让它在1.7.1版本中工作了,也遇到了缺少用户/密码提示的问题。感谢 https://dev59.com/K2s05IYBdhLWcg3wG-VR#9575906 提供的帮助... - sjas
3
检查用户对仓库是否具有读写权限。 - Céline Aussourd
42
将来展示示例HTTP头时,请勿粘贴“Authorization: Basic <stuff>”。这很容易被Base64解码并获取您的密码。@Mike:如果您自发布此问题以来没有更改GitHub密码,建议您这样做。 - FlipMcF
6
谢谢,我不知道这个事情。已经更改了密码。 - Mike
8
@Mike 没问题。现在我可以毫不掩饰地宣传一下我写的博客:http://goo.gl/bpae94 - FlipMcF
显示剩余9条评论
75个回答

0

我在Android Studio中遇到了同样的问题请求的URL返回错误:403

我按照以下步骤操作:

  1. 右键单击项目名称 ---> git ----> 添加
  2. 然后打开一个对话框 ----> 输入由GitHub生成的内容。
  3. 然后编写提交消息 ----> 并选择推送选项。

注意:因此,您必须在个人资料设置页面中生成访问令牌,并将其用作密码。


0

0

我在使用Bitbucket时也遇到过同样的问题,但我等了5分钟然后重试,之后就正常工作了。有时可能是提供者的问题。


嗯,就像这位先生所说的关于GitHub服务器的事情,是吧? - user456814
您可以从Bitbucket状态页面获取Bitbucket状态更新,也可以从他们的Twitter账户获取。 - user456814

0

我曾经遇到过同样的问题,并注意到我试图推送分支的存储库是“私有”的。因此,请尝试以下步骤:

  1. 确保您可以访问该私有存储库

  2. 首先fork存储库。您会注意到存储库URL将包含您的GitHub用户名

  3. 现在像这样克隆它--> git clone https://github.com/your-github-username/example-repository.git

  4. 进入克隆的存储库文件夹--> cd repository-directory

对于您的克隆存储库,您可以做任何想做的事情。在相同的克隆存储库目录中继续执行下一步操作

  1. 检查所有分支。这将列出可用的分支 --> git branch

  2. 现在创建您的分支 --> git checkout -b your-branch-name

  3. 运行 git branch 检查是否已创建您的分支

  4. 现在运行此命令 --> git add .

  5. 提交您的更改 --> git commit -m "your message"

  6. 推送您的分支 --> git push origin your-branch-name

  7. 检查 GitHub 网站以确保您的分支已被推送

就这些了


0

我正在使用 Mac,遇到了错误 "fatal: unable to access The requested URL returned error: 403."

我已经更改了 GitHub 帐户的详细信息。

我需要编辑我的 Keychain 条目以更新 GitHub 的用户名。您可以在 Mac 的顶部搜索中轻松找到 KeyChain。


0
当我们从Github克隆某人的存储库时,会出现此错误。通过使用以下命令更新origin,可以轻松解决此问题: git remote set-url origin '您的存储库origin' 然后执行以下操作: git push -f origin master 这对大家可能非常有帮助。

0

我也遇到了同样的问题。上述方法都对我无效。问题是Github已经阻止了我的写入权限。我已经更改了密码。现在我可以进行推送了。


0

尝试使用SSH密钥而不是HTTP创建您的源。

如果您可以使用SSH密钥启动,则URL以以下方式开头:

git@github.com:<YOUR REPO URL>

现在您可以将更改添加、提交并推送到相应的分支中了。


0
  1. 检查你是否在正确的分支上 git status
  2. 检查你的仓库权限(需要写入权限)

0

2021年8月13日,Github在CLI(命令行界面)中访问时取消了密码验证支持,并用个人访问令牌替换。

创建个人访问令牌的步骤

默认情况下,令牌始终包括对GitHub上所有公共存储库的只读访问权限。因此,在生成访问令牌时,需要选择适当的“范围”以授予推送或拉取权限。

公共存储库的范围是public_repo,私有存储库的范围是repo。具有其中一个范围的令牌是Git推送或拉取访问的最受限制的访问权限。

现在,当提示输入用户名和密码时,请提供您的GitHub用户名和访问令牌代替密码。

有关其他可用范围的说明,请参阅Github文档


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接