如何在代理后面使用 git
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/5529218/
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
How to use git behind a proxy
提问by
I am using msysgit from behind a proxy. As I said in question Getting git to work with a proxy server
我正在从代理后面使用 msysgit。正如我在问题中所说的让 git 与代理服务器一起工作
I have set system variable http_proxy
to a value. Later I call
我已将系统变量设置http_proxy
为一个值。后来我打电话
git config --global http.proxy $http_proxy
However, if I call something like:
但是,如果我调用类似的东西:
git clone git://git.savannah.gnu.org/gnuprologjava.git
It gives the following error:
它给出了以下错误:
git.savannah.gnu.org[0; 140.186.70.72]: errno=No error
fatal: unable to connect a socket (No error)
回答by Mat
回答by wimh
When you are on linux, see this page.
当您使用 linux 时,请参阅此页面。
On windows I have solved it this way;
在 Windows 上,我是这样解决的;
Install Cygwin, and select the socat package. Create a script gitproxy.cmd and save it in the path (I used C:\msysgit\cmd\gitproxy.cmd):
安装Cygwin,并选择 socat 包。创建脚本 gitproxy.cmd 并将其保存在路径中(我使用的是 C:\msysgit\cmd\gitproxy.cmd):
@echo off
C:\cygwin\bin\socat.exe - PROXY:192.168.100.1:\%1:\%2,proxyport=3128
(replace 192.168.100.1 and 3128 with your own proxy ip/port)
(将 192.168.100.1 和 3128 替换为您自己的代理 IP/端口)
Execute the following line to configure the proxy:
执行以下行来配置代理:
git config --global core.gitproxy gitproxy.cmd
Note that the proxy server must accept the CONNECT command for the git port (9418). I have added the following lines to the squid configuration to make this work:
请注意,代理服务器必须接受 git 端口 (9418) 的 CONNECT 命令。我在鱿鱼配置中添加了以下几行来完成这项工作:
acl SSL_ports port 9418 # git
acl Safe_ports port 9418 # git
(ie configure port 9418 the same way as port 443 in the proxy server)
(即9418端口和代理服务器443端口一样配置)
回答by Ravi Parekh
As this was answered by many but this is just for a WindowsUSER who is behind a proxy with auth.
由于许多人已经回答了这个问题,但这仅适用于使用身份验证的代理背后的Windows用户。
Re-Installing (first failed, don't remove).
重新安装(第一次失败,不要删除)。
Go to:
1. msysgit\installer-tmp\etc\gitconfig
Under [http]
proxy = http://user:pass@url:port
2. msysgit\installer-tmp\setup-msysgit.sh
export HTTP_PROXY="http://USER:[email protected]:8080"
if you have any special char in user/pass use url_encode
如果用户/密码中有任何特殊字符,请使用url_encode
Option 2: Set environment variable
选项 2:设置环境变量
HTTP_PROXY=http://proxy.com:8080
HTTP_PROXY= http://proxy.com:8080