为什么windows上的Git代理无法超时



简短摘要-我正在Windows 7机器上设置git代理,以指向本地运行的代理应用程序。当我停止运行应用程序(通过telnet测试验证)时,git clone命令将挂起,而不是标识一个关闭的套接字。我不能在Mac上复制这个。

我的问题是:为什么windows上的Git代理无法超时这是个bug还是故意的?

以下是我(在Mac上)确认无法在Mac上复制该问题的步骤。

MacBook-Pro:~ $ telnet localhost 1234
Trying ::1...
telnet: connect to address ::1: Connection refused
Trying 127.0.0.1...
telnet: connect to address 127.0.0.1: Connection refused
telnet: Unable to connect to remote host
MacBook-Pro:~ $ git config --global http.proxy http://localhost:1234
MacBook-Pro:~ $ git clone https://github.com/HaskVan/HaskellKoans
Cloning into 'HaskellKoans'...
fatal: unable to access 'https://github.com/HaskVan/HaskellKoans/': Failed to connect to localhost port 1234: Connection refused
MacBook-Pro:~ $ git config --global --unset http.proxy

我电脑上的等效序列是:

c:temp>telnet localhost 1234
Connecting To localhost...Could not open connection to the host, on port 1234: C
onnect failed
c:temp>git config --global http.proxy http://localhost:1234
c:temp>git clone https://github.com/HaskVan/HaskellKoans
Cloning into 'HaskellKoans'...
^C
c:temp>git config --global --unset http.proxy
c:temp>git clone https://github.com/HaskVan/HaskellKoans
fatal: destination path 'HaskellKoans' already exists and is not an empty direct
ory.
c:temp>git clone https://github.com/HaskVan/HaskellKoans
Cloning into 'HaskellKoans'...
remote: Counting objects: 205, done.
Rremote: Total 205 (delta 0), reused 0 (delta 0)eceiving objects:  38% (78/205)
Receiving objects:          205)
Receiving objects: 100% (205/205), 26.27 KiB | 0 bytes/s, done.
Resolving deltas: 100% (114/114), done.
Checking connectivity... done.

特别注意超时之后的^CCTRL-C)。这就是这个问题的意义所在。

我在Windows上运行的版本是:

c:temp>git --version
git version 1.9.0.msysgit.0

我在Mac上运行的版本是:

MacBook-Pro:~ $ git --version
git version 1.9.3 (Apple Git-50)

我看到在使用msysgit的代理后面工作:第一个git调用挂起,第二个调用通过。

在您的情况下,如果您想避免代理访问GitHub,您可以选择:

  • 仅为特定url指定代理(git1.8.5+)
  • 或者指定环境变量no.proxy以在访问github.com时避免代理

最新更新