配置的 http.proxy 适用于 git 但不适用于 jgit

Sep*_*935 6 git jgit

让我们首先显示 --global .gitconfig,就像 git 和 jgit 看到的那样!!!从 DOS 窗口以及从 Cgywin 窗口

E:\> git config --list --global
http.auth.preference=Basic
user.name=Josef Stadelmann
user.email=josef.stadelmann@axa-winterthur.ch
http.proxy=http://C770817:MyPassword@bcproxyserver.ch.winterthur.com:8080

E:\>
Run Code Online (Sandbox Code Playgroud)

现在让我们从带有 JGit 的 Cygwin 窗口中查看

$ jgit config --list --global
http.auth.preference=Basic
user.email=josef.stadelmann@axa-winterthur.ch
user.name=Josef Stadelmann
http.proxy=http://C770817:MyPassword@bcproxyserver.ch.winterthur.com:8080
Run Code Online (Sandbox Code Playgroud)

我们可以看到相同的配置 那为什么

C770817@C036357 ~
$ jgit ls-remote https://github.com/stadelma/HelloWorld.git
fatal: Connection time out: github.com
fatal: https://github.com/stadelma/HelloWorld.git: cannot open git-upload-pack
Run Code Online (Sandbox Code Playgroud)

超时但是

C770817@C036357 ~
$ git ls-remote http://github.com/stadelma/HelloWorld.git
35f375cb64208b64ed499c2a47727dfcd8813dea        HEAD
35f375cb64208b64ed499c2a47727dfcd8813dea        refs/heads/master

C770817@C036357 ~
$
Run Code Online (Sandbox Code Playgroud)

在读取相同的 .gitconfig 时正常工作

/cygdrive/e/mingw/home/.gitconfig
Run Code Online (Sandbox Code Playgroud)

???

欢迎任何建议 - 或者 - 我应该开始调试 jgit 吗?

约瑟夫

Von*_*onC 3

您可以尝试使用以下 java 选项来查看环境变量是否会更好地工作:

\n\n
-Dhttp.proxyHost=myproxyhosturl\n-Dhttp.proxyPort=8080\n-Dhttp.nonProxyHosts=\xe2\x80\x9dlocalhost|mybambooserverurl\xe2\x80\x9d\n
Run Code Online (Sandbox Code Playgroud)\n\n

正如在这个问题中:

\n\n
    \n
  • Dhttp.proxyHost\xe2\x80\x93 代理 IP 地址
  • \n
  • Dhttp.proxyPort\xe2\x80\x93 代理端口
  • \n
  • Dhttp.proxyUser\xe2\x80\x93 用户名(如果需要 HTTP 代理身份验证);
  • \n
  • Dhttp.proxyPassword\xe2\x80\x93 用户密码(如果需要 HTTP 代理身份验证)。
  • \n
\n