Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/git/24.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
推送到Git返回错误代码403致命:HTTP请求失败_Git_Github_Dvcs - Fatal编程技术网

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

推送到Git返回错误代码403致命:HTTP请求失败,git,github,dvcs,Git,Github,Dvcs,我能够通过HTTPS身份验证克隆此回购协议的副本。我已经做了一些提交,希望返回到GitHub服务器。在Windows7x64上使用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_

我能够通过HTTPS身份验证克隆此回购协议的副本。我已经做了一些提交,希望返回到GitHub服务器。在Windows7x64上使用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

403代码为“禁止”。服务器看到您的请求并拒绝了它。您有权限推送到该存储库吗?

已经解决了。我是通过HTTPS克隆的。设置我的公共SSH密钥,通过SSH进行克隆,然后通过SSH进行推送,解决了这个问题。

我刚刚遇到了同样的问题,并找到了原因

Github似乎只支持ssh方式来读写repo,尽管https方式也显示“读写”

因此,您需要将PC上的repo配置更改为ssh方式:

  • 编辑repo目录下的
    .git/config
    文件
  • 查找
    url=
    部分下的条目
    [远程“源站”]
  • 将其从
    url更改=https://MichaelDrogalis@github.com/derecerdmann/sunch\u call.git
    to
    url=git@github.com/derekerdmann/sunch\u call.git
    。也就是说,将
    @
    符号之前的所有文本更改为
    ssh://git
  • 保存
    config
    文件并退出。现在,您可以使用git push origin master在GitHub上同步您的回购

  • 其他建议切换到SSH的答案有点没有抓住要点。HTTPS是受支持的,但您必须使用GITHUB密码登录,而不是SSH密码(这正是给我相同错误的原因)

    我也遇到了同样的问题,但确保在终端密码提示下使用我的实际GitHub密码修复了该解决方案,而无需更改配置或求助于SSH

    注意这一点很重要的原因是,许多公共机构(比如我的学校)会阻止SSH,但允许HTTPS(这是我开始通过HTTPS克隆的唯一原因)


    希望这能帮助其他有同样问题的人…

    对于好奇的人来说,我的mac机器和lucid vm运行的是git 1.7.6和1.7.0.4,完全相同的回购协议可以从我的mac(较新的git)推送,但不能从vm推送

    相同的卷曲版本。也许一些较旧的git版本不支持https推送?

    这是一个小小的补充

    您可以使用
    git remote set url
    命令,而不是手动编辑
    .git/config
    文件

    在您的情况下,它应该是:

    git remote set-url origin ssh://git@github.com/derekerdmann/lunch_call.git
    
    我发现这比摆弄点文件更容易、更干净


    升级您的git。GitHub已经在回答了这个问题。

    我认为@deepwaters对于旧版本的回答是正确的。HTTPS URL需要有用户名。我有git 1.7.0.4,在我添加密码之前,
    git push origin master
    甚至不会要求输入密码。

    要绝对能够使用
    https
    协议登录,您应该首先将身份验证凭据设置为git远程URI

    git remote set-url origin https://yourusername@github.com/user/repo.git
    
    然后,在尝试推送git时,系统会要求您输入密码

    事实上,这是基于http身份验证格式的。您也可以设置密码:

    https://youruser:password@github.com/user/repo.git
    

    您应该知道,如果这样做,您的github密码将以明文形式存储在.git目录中,这显然是不可取的。

    我现在遇到了这个问题,结果是我的服务器/etc/resolver.conf文件的ip地址不正确。可能会帮助他人。

    url=https://MichaelDrogalis@github.com/derekerdmann/lunch_call.git 
    

    它起作用了


    不要忘记repo目录下“@.”

    编辑
    .git/config
    文件之前的“git”

    查找
    url=
    部分下的条目
    [远程“源站”]

    将其从
    url更改=https://github.com/rootux/ms-Dropdown.git
    https://USERNAME@github.com/rootux/ms Dropdown.git


    其中,
    USERNAME
    是您的github用户名

    这件事发生在我身上,因为我的同事意外地禁用了从中派生出此存储库的存储库。只需检查以确保原始git(集线器)回购实际上仍然存在。

    只需将您的用户名添加到url中,如下所示:

    请检查:
    这可能是一个会计问题。上游(私人)回购所有人的Github账户可能不是金融账户。我在客户信用卡过期的地方看到了这一点。

    我找到了这个问题的我自己的变体

    问题不是将协议从https更改为ssl,而是, 设置Github全局用户名和电子邮件!(我正试图推到一个 私有存储库

    git config --global user.email "your_github_email_@email.com"
    
    git config --global user.name "Your full name"
    

    我遇到了同样的错误,原因很愚蠢——我没有权限提交到选定的存储库。我不知道我必须这样做

  • 首先选择项目
  • 本地克隆存储库
  • 在本地提交我的更改
  • 将更改推送到我的github克隆
  • 请求将请求拉到上游

  • 中所述,Github有专门用于排除此错误的页面:


    在我的例子中,使用新版本的git(1.8.5.2)解决了这个问题。

    在Mac OS X上出现相同的错误和分辨率。

    一切都很顺利,直到我在GitHub上创建了一个新帐户,并试图推动它

    $ git push -u origin master
    
    并得到了错误信息:

    远程:对NEWUSER/NEWREPO.git的权限被OLDUSER拒绝。致命:无法访问“”:请求的URL返回错误:403

    它应该通过为全局或当前回购设置user.name来修复

    $ git config –-global user.name NEWUSER
    $ git config user.name NEWUSER
    
    但事实并非如此

    我通过从Keychain Access app的“密码”部分删除与GitHub关联的旧用户来修复它。然后push命令成功执行

    $ git push -u origin master
    

  • 单击您的存储库
  • 在右侧,单击“设置”
  • 在左侧选项面板上,单击“协作者”
  • 在GitHub中添加您知道的人名
  • 单击“添加协作者”
  • 在这之后,我们的“
    $ git config –-global user.name NEWUSER
    $ git config user.name NEWUSER
    
    $ git push -u origin master
    
    git remote set-url origin https://username@github.com/user/repo.git
    
    [core]
        repositoryformatversion = 0
        filemode = true
        bare = false
        logallrefupdates = true
    [remote "origin"]
        fetch = +refs/heads/*:refs/remotes/origin/*
        url = https://*username*@github.com/*username*/*repository*.git
    [branch "master"]
        remote = origin
        merge = refs/heads/master
    
    git remote set-url origin https://<username>@github.com/Path_to_repo.git
    
    git remote -v
    
    git remote set-url origin https://github.com/USERNAME/OTHERREPOSITORY.git
    
    >git config --global --unset-all credential.helper
    
    >git config --unset-all credential.helper
    
    >git config --system --unset-all credential.helper
    
    ssh-keygen -t rsa -C "your_email@example.com"
    
    ssh -T git@github.com
    clone the repo:
    git clone git://github.com/username/your-repository
    
    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