推送到GitHub错误:无法在.netrc文件中找到主机github.com;使用默认值

时间:2010-06-01 10:58:43

标签: git github git-push

Dunno发生了什么事,github对此问题没有回应,所以我在这里问。在一个月左右的时间里第一次尝试了一个git push并得到了这个。打开导出GIT_CURL_VERBOSE = 1然后按下并获取此信息:

localhost:send2mobile_rails phil$ 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... * Connected to github.com (207.97.227.239) port 443 (#0)
* SSL connection using DHE-RSA-AES256-SHA
* Server certificate:
*    subject: O=*.github.com; OU=Domain Control Validated; CN=*.github.com
*    start date: 2009-12-11 05:02:36 GMT
*    expire date: 2014-12-11 05:02:36 GMT
*    subjectAltName: github.com matched
*    issuer: C=US; ST=Arizona; L=Scottsdale; O=GoDaddy.com, Inc.; OU=http://certificates.godaddy.com/repository; CN=Go Daddy Secure Certification Authority; serialNumber=07969287
*    SSL certificate verify ok.
> GET /303devworks/send2mobile_rails.git/info/refs?service=git-receive-pack HTTP/1.1
User-Agent: git/1.7.1
Host: github.com
Accept: */*
Pragma: no-cache

< HTTP/1.1 401 Authorization Required
< Server: nginx/0.7.61
< Date: Tue, 01 Jun 2010 10:53:13 GMT
< Content-Type: text/html; charset=iso-8859-1
< Connection: keep-alive
< Content-Length: 0
< WWW-Authenticate: Basic realm="Repository"
< 
* Connection #0 to host github.com left intact
* Issue another request to this URL: 'https://303devworks@github.com/MYUSERHERE/send2mobile_rails.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)
* Server auth using Basic with user '303devworks'
> GET /303devworks/send2mobile_rails.git/info/refs?service=git-receive-pack HTTP/1.1
Authorization: Basic MzAzZGVfd29sa3M6Y29nbmwzNzIw
User-Agent: git/1.7.1
Host: github.com
Accept: */*
Pragma: no-cache

< HTTP/1.1 200 OK
< Server: nginx/0.7.61
< Date: Tue, 01 Jun 2010 10:53:13 GMT
< Content-Type: application/x-git-receive-pack-advertisement
< Connection: keep-alive
< Status: 200 OK
< Pragma: no-cache
< Content-Length: 153
< Expires: Fri, 01 Jan 1980 00:00:00 GMT
< Cache-Control: no-cache, max-age=0, must-revalidate
< 
* Expire cleared
* Connection #0 to host github.com left intact
Counting objects: 166, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (133/133), done.
* 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... * connected
* Connected to github.com (207.97.227.239) port 443 (#0)
* SSL re-using session ID
* SSL connection using DHE-RSA-AES256-SHA
* old SSL session ID is stale, removing
* Server certificate:
*    subject: O=*.github.com; OU=Domain Control Validated; CN=*.github.com
*    start date: 2009-12-11 05:02:36 GMT
*    expire date: 2014-12-11 05:02:36 GMT
*    subjectAltName: github.com matched
*    issuer: C=US; ST=Arizona; L=Scottsdale; O=GoDaddy.com, Inc.; OU=http://certificates.godaddy.com/repository; CN=Go Daddy Secure Certification Authority; serialNumber=07969287
*    SSL certificate verify ok.
* Server auth using Basic with user 'MYUSERHERE'
> POST /303devworks/send2mobile_rails.git/git-receive-pack HTTP/1.1
Authorization: Basic JzAzZGV1d29ya3M6Y25nb29zNzIq
User-Agent: git/1.7.1
Host: github.com
Accept-Encoding: deflate, gzip
Content-Type: application/x-git-receive-pack-request
Accept: application/x-git-receive-pack-result
Expect: 100-continue
Transfer-Encoding: chunked

* The requested URL returned error: 411
* Closing connection #0
error: RPC failed; result=22, HTTP code = 411
Writing objects: 100% (140/140), 2.28 MiB | 1.93 MiB/s, done.
Total 140 (delta 24), reused 0 (delta 0)
^C
localhost:send2mobile_rails phil$ 

4 个答案:

答案 0 :(得分:17)

我遇到了同样的问题,并认为它与您尝试推送的回购邮件的大小(编辑或特定文件的大小)有关。

基本上我能够创建新的repos并将它们推送到github。但现有的不行。

HTTP错误代码似乎支持我,它是一个'需要长度'错误。所以也许它太大而无法计算或最大化。谁知道呢。

修改

  

我发现问题可能是   文件很大。我有一个更新   即使我有,也不会推   成功推动到那一点。   提交中只有一个文件   但它碰巧是1.6M

     

所以我添加了以下配置更改

     

git config http.postBuffer 524288000

     

允许最大文件大小500M和   然后我的推动工作。它可能是   这是最初的问题   在http上推了一个大的回购   协议

结束编辑

我可以让它工作的方式(在修改postBuffer之前编辑)是为了重新设置我的仓库,将其复制到可以通过ssh执行git的机器上,并将其推送到github。然后,当您尝试从原始服务器执行推/拉时,它应该通过https工作。 (因为它比原始推送的数据量要小得多)。

希望这有帮助。

答案 1 :(得分:7)

我遇到了同样的问题。这就是我解决问题的方法。

  1. 我增加了缓冲区大小

    git config http.postBuffer 524288000

  2. 然后我检查了服务器中的用户,并删除了我的用户名。所以我使用以下命令sudo htpasswd -c /etc/users dilip_rajkumar

  3. 重新创建了该文件

    希望这对某人有所帮助..

答案 2 :(得分:4)

看起来你正试图使用​​“smart http(s) protocol”,GitHub now supports 我们假设您没有代理问题或防火墙问题。

您的远程上游回购地址是什么? (git remote -v show列出什么?)

我建议:

    machine github.com
    login your_github_login
    password your_github_password
  • 再次尝试克隆您的回购git clone https://github.com/your_github_login/gitrepo.git,并推送该实例。

注意:作为Noufal Ibrahim注释,您可以使用ssh(除非阻止ssh端口,只允许使用http / https连接)

git clone ssh://user@server:project.git

答案 3 :(得分:1)

对于那些在创建新的.netrc文件时遇到问题,请确认它在您的HOME目录(cd~ /)中,确保它是可读的(chmod 600~ / .netrc),并确保它看起来像这样:

机器github.com
登录yourgithublogin
密码yourgithubpassword