Git 错误:致命:无法连接套接字(参数无效)
我的 MSysGit (Windows 上的 Git)在我的家用机器上运行得很好,但是在工作中,我们使用 Microsoft ISA 代理,当我执行 Git 时,出现以下错误克隆:
H:
cd \
git clone git://github.com/akitaonrails/vimfiles.git
输出:
Initialized empty Git repository in H:/vimfiles/.git/
github.com[0: 65.74.177.129]: errno=Invalid argument
fatal: unable to connect a socket (Invalid argument)
我已尝试将 http_proxy 环境变量设置为:
http://our-proxy-server:8088
我已设置 Git http.proxy 配置指令:
git config --global http.proxy http://our-proxy-server:8088
以上两者都没有什么区别。
使用 http://
而不是 git://
进行 Git 克隆会产生以下结果:
H:
cd \
git clone http://github.com/akitaonrails/vimfiles.git
Output:
Initialized empty Git repository in H:/vimfiles/.git/
fatal: http://github.com/akitaonrails/vimfiles.git/info/refs download error - The requested URL returned error: 407
407 当然是身份验证错误。
有没有办法让 Git 在代理(特别是 ISA 代理)后面工作? 我不知道这是否值得追求。
I've got MSysGit (Git on Windows) working just fine on my home machine, but at work, where we are behind a Microsoft ISA proxy, I get the following error when I do a Git clone:
H:
cd \
git clone git://github.com/akitaonrails/vimfiles.git
Output:
Initialized empty Git repository in H:/vimfiles/.git/
github.com[0: 65.74.177.129]: errno=Invalid argument
fatal: unable to connect a socket (Invalid argument)
I've tried setting the http_proxy environment variable to:
http://our-proxy-server:8088
I've set the Git http.proxy configuration directive:
git config --global http.proxy http://our-proxy-server:8088
Neither of the above makes a difference.
Doing a Git clone with http://
instead of git://
yields this:
H:
cd \
git clone http://github.com/akitaonrails/vimfiles.git
Output:
Initialized empty Git repository in H:/vimfiles/.git/
fatal: http://github.com/akitaonrails/vimfiles.git/info/refs download error - The requested URL returned error: 407
407 is of course an authentication error.
Is there a way to get Git working from behind a proxy, specifically an ISA proxy? I don't know if it's going to be worth pursing this.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(7)
我有完全相同的错误; 但
~/.gitconfig
全局配置文件是关键。如果您有带有身份验证的代理,则需要将其放入:
并且它可以正常工作(使用“
git clone http:
”)详细说明相同设置的博客示例:GIT 通过 HTTP 克隆:谁知道?
如果仍然失败407,这可能与 git-fetch 丢失身份验证令牌的问题有关第二个 HTTP GET。 更新版本的 libcurl可能需要。
2011 年 1 月更新:jbustamovej 在 他的回答(已投票) 他的博客文章“GitHub 背后的企业代理",其中添加了以下内容:
I had the exact same error; but the
~/.gitconfig
global config file was the key.If you have a proxy with authentication you need to put in it:
And it just works (with '
git clone http:
')Example of a blog detailing the same setup: GIT clone over HTTP: who knew?
If it still fails in 407, it could be related to a problem with git-fetch losing authentication tokens on the second HTTP GET. A more recent version of libcurl might be needed.
Update January 2011: jbustamovej mentions in his answer (upvoted) his blog post "GitHub Behind Corporate Proxy", which adds this:
即使配置代理后,您也可能无法连接,因为代理不允许 Git 协议流量。 在这种情况下,您可能需要尝试使用“http”而不是“git”。
此外,如果您使用自动代理配置文件 (.pac),只需在文本编辑器中打开它即可。 这是一种非常容易遵循的脚本语言,有很多条件可以重定向到最有效的代理。 找到允许通用流量的代理(通常是最后配置的代理),并按照上面的评论中所述进行配置。
Even after configuring the proxy, you might be unable to connect, since the proxy is disallowing Git protocol traffic. In this case, you might want to try using "http" instead of "git"
Also, if you are using an automated proxy config file (.pac), just open it in a text editor. It is quite a easy to following scripting language, with a bunch of conditions to redirect to the most efficient proxy. Find the one that allows general purpose traffic (typically, the last configured proxy), and configure it as mentioned in the comment above.
您有 SOCKS 代理吗? 如果有的话,您可以尝试使用 FreeCap 来袜子化您的 Git 连接。 我已经以这种方式使用 Git 一段时间了。
如果没有,仍然尝试 FreeCap。 IIRC 它也许能够使用 HTTP 代理,但我还没有尝试过。
我通常使用 FreeCap 来袜子化cmd.exe,从那时起(几乎)我从该会话启动的所有 cmdline 程序也都是袜子化的。 这就是我推荐 Free Cap 的原因,因为 SocksCap(另一种替代方案)不能以这种方式工作。
至于使用http.proxy,由于某种原因,它对我的 MinGW 版本和我公司的 HTTP 代理从来不起作用。
Do you have SOCKS proxy? If you have, you could try FreeCap to socksify your Git connection. I've been using Git this way for a while.
If not, still try FreeCap. IIRC it might be able to use HTTP proxies, but I haven't tried that.
I usually socksify cmd.exe using FreeCap, and from then on (almost) all cmdline programs that I start from that session are socksified too. That's why I recommended Free Cap, since SocksCap (another alternative) doesn't work that way.
As for using http.proxy, it for some reason never worked for me with the MinGW version and my company's HTTP proxies.
我设法通过一条非常复杂的路线让它工作。 具体方法如下:
令人惊讶的是,它似乎有效,尽管我还没有测试所有内容。 当然,它会克隆,这是一个开始。
I've managed to get it working via a very convoluted route. Here's how:
Amazingly, it seems to work, although I've not tested everything yet. It'll clone, certainly, which is a start.
这对我有用:
Here is what worked for me:
在从 GitHub 收到 407 错误和其他垃圾后,Python 2.7 和 ntlmaps 对我有用。
文件.gitconfig:
Python 2.7 and ntlmaps worked for me after getting 407 errors and other junk from GitHub.
File .gitconfig:
我在 Windows 7 上遇到了这个问题:
输出:
我终于意识到这是 AVG AntiVirus 软件正在运行。 我禁用了AVG中的“驻留盾”,它的作用就像一个魅力。
输出:
I had this problem on Windows 7:
Output:
I finally realized it was AVG AntiVirus software running. I disabled the "resident shield" within AVG, and it worked like a charm.
Output: