windows Git 错误:致命:无法连接套接字(无效参数)

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/496277/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-09 06:00:27  来源:igfitidea点击:

Git error: fatal: unable to connect a socket (Invalid argument)

windowsgitproxymsysgit

提问by Charles Roper

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:

我的 msysGit(Windows 上的 Git)在我的家用机器上运行得很好,但是在工作中,我们在 Microsoft ISA 代理后面,当我执行 git clone 时出现以下错误:

H:\>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)

I've tried setting the http_proxy environment variable to:

我试过将 http_proxy 环境变量设置为:

http://our-proxy-server:8088

I've set the git http.proxy configuration directive:

我已经设置了 git http.proxy 配置指令:

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:

http://而不是做一个 git clone 会git://产生这个:

H:\>git clone http://github.com/akitaonrails/vimfiles.git
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.

407当然是认证错误。

So my question is: has anyone managed 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. Any help very much appreciated.

所以我的问题是:有没有人设法让 git 从代理后面工作,特别是 ISA 代理?我不知道这是否值得追求。非常感谢任何帮助。

Thanks!

谢谢!

回答by VonC

I had the exact same error; but the ~/.gitconfigglobal config filewas the key.

我有完全相同的错误;但~/.gitconfig全局配置文件是关键。

If you have a proxy with authentication you need to put in it:

如果您有一个带有身份验证的代理,则需要将其放入:

git config --global http.proxy http://login:password@our-proxy-server:8088

And it just works (with 'git clone http:')

它只是有效(使用“ git clone http:”)

Example of a blog detailing the same setup: GIT clone over HTTP: who knew?

详细介绍相同设置的博客示例:GIT clone over HTTP:谁知道?



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 libcurlmight be needed.

如果在 407 中仍然失败,则可能与git-fetch 在第二个 HTTP GET 上丢失身份验证令牌的问题有关。一个更近的libcurl版本可能需要。



Update January 2011: jbustamovejmentions in his answer (upvoted)his blog post "GitHub Behind Corporate Proxy", which adds this:

2011 年 1 月更新:jbustamovej他的回答中提到(赞成)他的博客文章“ GitHub 背后的企业代理”,其中补充说:

It's important to note that if your login has a backslash, as in domain\login, you must escape the backslash, as in:

重要的是要注意,如果您的登录名有反斜杠,如domain\login您必须转义反斜杠,如:

git config --global http.proxy http://domain\\login:password@our-proxy-server:8088

回答by shiva

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"

即使在配置代理之后,您也可能无法连接,因为代理不允许 git 协议流量。在这种情况下,您可能想尝试使用“http”而不是“git”

H:>git clone http://github.com/akitaonrails/vimfiles.git

H:>git clone http://github.com/akitaonrails/vimfiles.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 re-direct 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.

此外,如果您使用的是自动代理配置文件 (.pac),只需在文本编辑器中打开它。遵循脚本语言非常容易,有很多条件可以重定向到最有效的代理。找到允许通用流量的那个(通常是最后配置的代理),并按照上面的评论中提到的进行配置。

回答by Marko

Do you have SOCKS proxy? If you have, you caould try FreeCapto socksify your git connection. I've been using git this way for a while.

你有SOCKS代理吗?如果有,您可以尝试使用FreeCap来对您的 git 连接进行袜子化。我以这种方式使用 git 已经有一段时间了。

If not, still try FreeCap. IIRC it might be able to use http proxies, but I haven't tried that.

如果没有,还是试试 FreeCap。IIRC 它可能能够使用 http 代理,但我还没有尝试过。

EDIT: I usualy socksify cmd.exeusing 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.

编辑:我通常使用 FreeCap对cmd.exe进行袜子化,从那时起(几乎)我从该会话启动的所有 cmdline 程序也都是袜子化的。这就是我推荐 Free Cap 的原因,因为 SocksCap(另一种选择)不能那样工作。

As for using http.proxy, it for some reason never worked for me with mingw version and my company http proxies.

至于使用 http.proxy,由于某种原因,它从来没有对我使用 mingw 版本和我公司的 http 代理工作过。

回答by Charles Roper

I've managed to get it working via a very convoluted route. Here's how:

我设法通过一条非常复杂的路线让它工作。就是这样:

  1. I have OpenSSH running on my home machine (a Vista box) running under Cygwin
  2. I am using Bitvise Tunnelier's Dynamic tunneling via integrated SOCKS/HTTP CONNECT proxy.
  3. I then use Freecap(thanks Marko) to "SOCKify" GIT-GUI. Unfortunately, you have to setup each .exe individually and run them from within Freecap, so you can't univerally SOCKify all of the git command line tools. You can setup explicit command-line commands within Freecap, but you have to setup each individually, which kind of defeats the purpose. This is why I've just setup GIT-GUI in this crazy elaborate system
  1. 在 Cygwin 下运行的家用机器(Vista 机器)上运行OpenSSH
  2. 我正在通过集成的 SOCKS/HTTP CONNECT 代理使用 Bitvise Tunnelier 的动态隧道
  3. 然后我使用Freecap(感谢 Marko)来“SOCKify”GIT-GUI。不幸的是,您必须单独设置每个 .exe 并在 Freecap 中运行它们,因此您无法统一对所有 git 命令行工具进行 SOCKify。您可以在 Freecap 中设置显式命令行命令,但是您必须单独设置每个命令,这违背了目的。这就是为什么我刚刚在这个疯狂的精心设计的系统中设置了 GIT-GUI

Amazingly, it seems to work, although I've not tested everything yet. It'll clone, certainly, which is a start.

令人惊讶的是,它似乎有效,尽管我还没有测试过所有东西。它当然会克隆,这是一个开始。

If anyone has a better solution, I'm all ears.

如果有人有更好的解决方案,我会全力以赴。

回答by Matt Hinze

Python 2.7 and ntlmapsworked for me after getting 407 errors and other junk from GitHub.

在从 GitHub 收到 407 错误和其他垃圾后,Python 2.7 和ntlmaps对我有用。

.gitconfig :

.gitconfig :

[http]
      proxy = http://127.0.0.1:5865

回答by Vlad Bezden

Here is what worked for me:

这是对我有用的:

git config --global http.proxy http://login:password@PROXY_SERVER:PORT
git config --global http.sslVerify false

回答by Jay

I had this problem on windows7:

我在 windows7 上遇到了这个问题:

$ git clone git://github.com/facebook/php-sdk.git
Initialized empty Git repository in c:/Users/Jay/temp/php-sdk/.git/
github.com[0: 207.97.227.239]: errno=No error
fatal: unable to connect a socket (No error)

Finally realized it was AVG anti virus software running. I disabled the "resident shield" within AVG and works like a charm now.

终于意识到是AVG杀毒软件在运行。我禁用了 AVG 中的“常驻盾牌”,现在就像一个魅力。

$ git clone git://github.com/facebook/php-sdk.git
Initialized empty Git repository in c:/Users/Jay/temp2/php-sdk/.git/
remote: Counting objects: 223, done.
remote: Compressing objects: 100% (179/179), done.
emote: Total 223 (delta 84), reused 0 (delta 0)
Receiving objects: 100% (223/223), 37.32 KiB, done.
Resolving deltas: 100% (84/84), done.