我无法安装Homebrew(请参阅我在 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后缀的 URL 时,我遇到了同样的问题:
$ 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:
我不认为这是一个代理问题(正如尼尔的回答中所建议的那样)。
我又试了一次,它奏效了!
$ 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 或 homebrew 有一些他们已经修复的问题。