我的 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
输出:
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 代理)后面工作?我不知道这是否值得追求。
~/.gitconfig
全局配置文件 是关键。
如果您有带有身份验证的代理,则需要将其放入:
git config --global http.proxy http://login:password@our-proxy-server:8088
它就可以工作(使用“
git clone http:
”)
详细介绍相同设置的博客示例:通过 HTTP 进行 GIT 克隆:谁知道?
如果在 407 中仍然失败,则可能与 git-fetch 在第二次 HTTP GET 上丢失身份验证令牌的问题有关。可能需要更新版本的 libcurl。
jbustamovej 在他的回答(已投票) 中提到了他的博客文章“GitHub Behind Corporate Proxy”,其中添加了以下内容:
需要注意的是,如果您的登录名有反斜杠,如
domain\login
,您必须转义反斜杠,如:git config --global http.proxy http://domain\\\login:password@our-proxy-server:8088
代理吗?如果有,您可以尝试使用 FreeCap 来袜子化您的 Git 连接。我已经以这种方式使用 Git 一段时间了。 如果没有,仍然尝试 FreeCap。 IIRC 它也许能够使用 HTTP 代理,但我还没有尝试过。
我通常使用FreeCap来socksify
cmd.exe,从那时起(几乎)我从该会话启动的所有cmdline程序也都是socksify的。这就是为什么我推荐 Free Cap,因为 SocksCap(另一种替代方案)不能那样工作。 至于使用
http.proxy,由于某种原因,它对我的 MinGW 版本和我公司的 HTTP 代理从来不起作用。
我在我的家用计算机(Vista 盒子)上运行 OpenSSH
如果有人有更好的解决方案,我洗耳恭听。
在从 GitHub 收到 407 错误和其他垃圾后,
git config --global http.proxy http://login:password@PROXY_SERVER:PORT
git config --global http.sslVerify false
$ 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)
终于发现是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.