为什么 git fetch 会因 https://github.com/mxcl/homebrew origin 的“无法解析主机:(nil)...”而失败?

Dar*_*zer 4 git https github

我无法安装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
Run Code Online (Sandbox Code Playgroud)

为什么我收到这个错误?

更新:(回应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
Run Code Online (Sandbox Code Playgroud)

更新#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
Run Code Online (Sandbox Code Playgroud)

我查看了我的~/.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
Run Code Online (Sandbox Code Playgroud)

我的理论是 github 或 homebrew 有一些他们已经修复的问题。

小智 5

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

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
Run Code Online (Sandbox Code Playgroud)

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

$ git config --global --unset core.gitproxy
Run Code Online (Sandbox Code Playgroud)