我能够通过HTTPS身份验证克隆此repo的副本 . 我做了一些提交,想要推回到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
30 回答
这可能是一个会计问题 . 上游(私人)回购所有者的Github账户可能不属于财务状况 . 我已经看到客户的信用卡过期了 .
对我有用的是从http改为ssh:
然后用
git remote -v
检查我遇到过同样的问题 . 我的情况是:我在github上创建它之前在本地初始化了git repo,然后我尝试添加远程分支 . 我通过更改操作顺序解决了我的问题:在github网站上创建了一个repo,然后在本地插入了它 . 但是他们不喜欢像我一样从命令行做所有事情 .
在gitbox app中将https更改为 http 之后,它对我有用 .
我刚刚遇到同样的问题,只是想出了原因 .
Github似乎只支持ssh方式来读取和写入repo,尽管https方式也显示“Read&Write” .
因此,您需要将PC上的repo配置更改为ssh方式:
在您的repo目录下编辑
.git/config
文件在
[remote "origin"]
部分找到url=
条目将其从
url=https://MichaelDrogalis@github.com/derekerdmann/lunch_call.git
更改为url=ssh://git@github.com/derekerdmann/lunch_call.git
. 也就是说,将@
符号之前的所有文本更改为ssh://git
保存
config
文件并退出 . 现在您可以使用git push origin master
在GitHub上同步您的仓库为了能够使用
https
协议进行登录,您应首先将您的身份验证凭据设置为git Remote URI :然后在尝试
git push
时会要求您输入密码 .实际上,这是http身份验证格式 . 您也可以设置密码:
您应该知道,如果您这样做,您的github密码将以纯文本形式存储在.git目录中,这显然是不受欢迎的 .
Sean's answer的一小部分 .
您可以使用
git remote set-url
命令而不是手动编辑.git/config
文件 .在你的情况下它应该是:
我发现它比使用点文件更容易,更干净 .
编辑repo目录下的
.git/config
文件在
[remote "origin"]
部分下找到url=
条目将其从
url=https://github.com/rootux/ms-Dropdown.git
更改为https://USERNAME@github.com/rootux/ms-Dropdown.git
其中
USERNAME
是您的github用户名其他建议切换到SSH的答案错过了重点 . 支持HTTPS,但您必须使用GITHUB密码登录,而不是使用SSH密码(这是给出了同样错误的错误) .
我遇到了同样的问题,但确保在终端密码提示下使用我的实际GitHub密码修复了解决方案,没有对配置进行任何更改,也没有使用SSH .
重要的是要注意这一点,许多公共机构(例如我的学校)将阻止SSH,但允许HTTPS(这是我首先开始通过HTTPS克隆的唯一原因) .
希望能帮助其他人解决同样的问题......
Mac OS X. 上的错误和解决方案相同
一切都很好,直到我创建了 new account on GitHub 并试图推动
并得到错误:
remote:拒绝给OLDUSER的NEWUSER / NEWREPO.git . 致命:无法访问'https://github.com/NEWUSER/NEWREPO.git/':请求的URL返回错误:403
它应该通过为全局或当前repo设置user.name来修复
但事实并非如此 .
密码部分下的 I got it fixed by deleting the OLDUSER associated with GitHub from Keychain Access app . 然后push命令成功 .
reference
我认为@dewwaters对旧版本的答案是正确的 . HTTPS URL需要具有用户名 . 我有git 1.7.0.4和
git push origin master
甚至不会要求密码,直到我添加它 .这对我有用 - :
希望能帮助到你
升级你的git . GitHub已在https://help.github.com/articles/error-the-requested-url-returned-error-403回答了这个问题 .
我实际上有一个非常简单的解决方案 . 我所做的只是在克隆存储库后以不同方式编辑git配置文件 . 您需要在默认的 config 文件中编辑远程源URL . 它应该如下所示
403代码是“禁止的” . 服务器看到了您的请求并拒绝了它 . 您是否有权推送到该存储库?
弄清楚了 . 我通过HTTPS克隆 . 设置我的公共SSH密钥,通过SSH克隆,并通过SSH修复它 .
只需将您的用户名添加到网址中,如下所示:https://islam9@github.com/islam9/bootstrap-rtl
请检查:http://islamkhalil.wordpress.com/2012/12/06/github-error-pushing-to-git-returning-error-code-403-fatal/
单击您的存储库
在右侧,单击"Settings"
在左侧选项面板上,单击"Collaborators"
在GitHub中添加您知道的人名
点击"Add Collaborators"
在此之后,我们的“推送到Git”工作得很好 .
如果您使用的是Windows,有时可能会发生这种情况,因为Windows会在其自己的存储中存储外部存储库(在我们的示例中为github)的凭据 . 保存在那里的凭证可能与您现在需要的凭据不同 .
因此,要避免此问题,只需在此存储中找到github并删除已保存的凭据 . 在此之后,推送git将请求您的凭据,并允许您推送 .
对于任何好奇的人,我的mac机器vs lucid vm运行git 1.7.6 vs 1.7.0.4,并且完全相同的repo可以从我的mac(更新的git)推送但不是VM
相同的卷曲版本 . 也许一些较旧的git版本不支持https推送?
改变它
至
有用!
不要忘记之前的“git”“@” .
我面临同样的错误,原因是愚蠢的 - 我没有权限提交选定的存储库 . 我不知道我必须这样做
前叉选择项目
本地克隆存储库
在本地提交我的更改
将更改推送到我的github克隆
请求上游请求
如https://help.github.com/categories/63/articles中所述
添加用户名作为URL的一部分,并且发生此错误是因为git命令正在命中http而不是https . 所以设置网址
之后,系统将提示您输入密码:
什么对我有用:
我的回购是一个叉子,仍然与父母回购挂钩 .
会告诉你它是否是你的回购 .
允许您将其重新配置为您的仓库,然后允许您推送 .
对于那些在使用 ssh (根据Xiao)或 http urls时被拒绝403错误的人尝试这些命令
拥有管理员权限
我想出了我自己对这个问题的看法 .
问题不是将协议从https更改为ssl,而是设置Github全局用户名和电子邮件! (我试图推送到私人存储库 .
Github有专门用于解决此错误的页面:
https://help.github.com/articles/https-cloning-errors
在我的例子中,事实证明使用新版本的git(1.8.5.2)解决了这个问题 .
上述答案都不适用于我的
enterprise
GitHub帐户 . 按照以下步骤通过ssh密钥生成方式进行推送 .创建一个回购 . 确保其中至少有一个文件(甚至只是README)生成ssh密钥:
ssh-keygen -t rsa -C "your_email@example.com"
将文件〜/ .ssh / id_rsa.pub的内容复制到GitHub帐户设置中的SSH密钥 . 测试SSH密钥:ssh -T git@github.com clone the repo: git clone git://github.com/username/your-repository
现在cd到您的git clone文件夹并执行:git remote set-url origin git@github.com:username/your-repository.git
现在尝试编辑文件(尝试自述文件)然后执行:git add -A git commit -am "my update msg" git push -u origin master
我现在遇到了这个问题,事实证明我的服务器/etc/resolver.conf文件有一个错误的IP地址 . 可能会帮助别人 .
这发生在我身上,因为我的同事意外地禁用了此存储库所分配的存储库 . 只是可以检查以确保原始git(hub)repo实际上仍然存在 .