为什么使用https://github.com/mxcl/homebrew origin将git fetch与“无法解析主机:( nil)...”失败?

时间:2013-08-17 16:10:27

标签: git github https

我无法安装Homebrew(请参阅我的question on apple.stackexchange.com),所以我查看了https://raw.github.com/mxcl/homebrew/go Ruby脚本并尝试了它运行的相同命令:

$ git init -q
$ git remote add origin https://github.com/mxcl/homebrew
$ git fetch origin master:refs/remotes/origin/master -n
error: Could not resolve host: (nil); nodename nor servname provided, or not known while accessing https://github.com/mxcl/homebrew/info/refs?service=git-upload-pack
fatal: HTTP request failed

为什么我收到此错误?

更新(响应madhead的回答)

当我使用带有 .git 后缀的网址时,我遇到同样的问题:

$ git init -q
$ git remote add origin https://github.com/mxcl/homebrew.git
$ git fetch origin master:refs/remotes/origin/master -n
error: Could not resolve host: (nil); nodename nor servname provided, or not known while accessing https://github.com/mxcl/homebrew.git/info/refs?service=git-upload-pack
fatal: HTTP request failed

更新#2:

我认为这不是代理问题(如neil's回答中所述)。

我再试一次这很有效!

$ git init -q
$ git remote add origin https://github.com/mxcl/homebrew
$ git fetch origin master:refs/remotes/origin/master -n
remote: Counting objects: 126721, done.
remote: Compressing objects: 100% (59085/59085), done.
remote: Total 126721 (delta 89963), reused 100145 (delta 66623)
Receiving objects: 100% (126721/126721), 19.68 MiB | 702 KiB/s, done.
Resolving deltas: 100% (89963/89963), done.
From https://github.com/mxcl/homebrew
 * [new branch]      master     -> origin/master

我查看了我的~/.gitconfig文件,发现我已经定义了一个代理。当我遇到问题时,我认为已经存在,但确认我删除了它并得到了一个不同的错误:

$ git fetch origin master:refs/remotes/origin/master -n
error: Failed connect to github.com:443; Connection refused while accessing https://github.com/mxcl/homebrew/info/refs?service=git-upload-pack
fatal: HTTP request failed

我的理论是,github或自制软件有一些他们已经修复过的问题。

3 个答案:

答案 0 :(得分:4)

对于那些不在代理后面时出现此错误的人:

error: Could not resolve host: (nil); nodename nor servname provided, or not known while accessing https://github.com/mxcl/homebrew/info/refs?service=git-upload-pack
fatal: HTTP request failed

解决方案可能是清除git代理设置:

$ git config --global --unset core.gitproxy

答案 1 :(得分:3)

对我而言,这与代理问题有关。当我在VPN上时,我需要添加

[http]
proxy = http://proxy.example.com

到我的~/.gitconfig,如果我不在VPN上,则无法找到此代理。

答案 2 :(得分:0)

您的远程网址不正确,应该是https://github.com/mxcl/homebrew.git .git 后固定)而不是https://github.com/mxcl/homebrew。您可以从Github UI复制URL以防止此类拼写错误。