簡體   English   中英

推送到 GitHub 錯誤:在 .netrc 文件中找不到主機 github.com; 使用默認值

[英]Push to GitHub error: Couldn't find host github.com in the .netrc file; using defaults

我不知道,這是怎么回事,我沒有收到 github 的回復。 我在一個月左右的時間里第一次嘗試了 git push 並得到了這個。 打開 export 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$ 

我遇到了同樣的問題,並認為這與您嘗試推送的存儲庫的大小(已編輯或特定文件的大小)有關。

基本上我能夠創建新的存儲庫並將它們推送到 github。 但是現有的一個行不通。

HTTP 錯誤代碼似乎支持我,它是“需要長度”錯誤。 所以也許它太大而無法計算或超過最大值。 誰知道。

編輯

我發現問題可能是文件很大。 我有一個更新不會推送,即使我已經成功推送到那個點。 提交中只有一個文件,但恰好是 1.6M

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

git 配置 http.postBuffer 524288000

允許最大文件大小為 500M,然后我的推送有效。 這可能是最初通過 http 協議推送大型 repo 的問題。

結束編輯

我可以讓它工作的方式(在我修改 postBuffer 之前編輯)是將我的 repo tar up,將它復制到一台可以通過 ssh 執行 git 的機器,然后將它推送到 github。 然后,當您嘗試從原始服務器執行推/拉操作時,它應該可以通過 https 運行。 (因為它的數據量比原始推送要少得多)。

希望這可以幫助。

我遇到了同樣的問題。 這就是我解決我的問題的方法。

  1. 我增加了緩沖區大小

    git 配置 http.postBuffer 524288000

  2. 然后我檢查了服務器中的用戶,我的用戶名被刪除了。 所以我使用以下命令重新創建了文件sudo htpasswd -c /etc/users dilip_rajkumar

希望這可以幫助某人..

看起來您正在嘗試使用GitHub 現在支持的智能 http(s) 協議”進行推送。
假設您沒有代理問題或防火牆問題。

你的遠程上游回購地址是什么?
(什么git remote -v show列表?)

我會推薦:

machine github.com
    login your_github_login
    password your_github_password
  • 再次嘗試克隆您的 repo git clone https://github.com/your_github_login/gitrepo.git ,並推送該實例。

注意:正如Noufal Ibrahim評論的那樣,您可以使用 ssh(除非 ssh 端口被阻止,否則您只能使用 http/https 連接)

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

對於那些在創建新 .netrc 文件時遇到問題的人,請驗證它是否在您的 HOME 目錄 (cd ~/) 中,確保您可以讀取它 (chmod 600 ~/.netrc),並確保它看起來像這樣:

機器 github.com
登錄你的github登錄
密碼你的github密碼

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM