如何设置Git以通过代理

Pet*_*son 29 git proxy cygwin github

我想在工作时连接到GitHub并需要通过http代理.我可以使用命令使用cURL离开FTP

curl -v -g --ftp-pasv --upload-file MYFILE --proxy PROXYADDRESS:PROXYPORT --proxy-ntlm --proxy-user WINDOWSDOMAIN\WINDOWSUSER:WINDOWSPASSWORD ftp://FTPUSER:FTPPASS@FTPURL/

到目前为止我还没能为Git提供等效的设置.

我尝试按照cygwin下的使用Github通过Draconian代理的说明.

我已经安装了开瓶器并试图通过SSH连接到GitHub

ssh github.com
Run Code Online (Sandbox Code Playgroud)

要么

ssh ssh.github.com
Run Code Online (Sandbox Code Playgroud)

我回来了

ssh:无法解析主机名ssh.github.com:提供的主机名或服务名,或者未知.

我试过设置http和https代理.

这是git --config -l的输出

core.symlinks=false
core.autocrlf=true
color.diff=auto
color.status=auto
color.branch=auto
color.interactive=true
pack.packsizelimit=2g
help.format=html
http.sslcainfo=C:/Program Files/Git/bin/curl-ca-bundle.crt
sendemail.smtpserver=/bin/msmtp.exe
diff.astextplain.textconv=astextplain
user.name=Peter Wilkinson
user.email=someemail@gmail.com
github.user=ProggerPete
github.token=shouldprobablykeepthissecret
http.proxy=http://somedomain\someuser:somepass@10.167.116.142:80
https.proxy=http://somedomain\someuser:somepass@10.167.116.142:80
Run Code Online (Sandbox Code Playgroud)

我也跑了

export https_proxy=http://somedomain\someuser:somepass@10.167.116.142:80
export http_proxy=http://somedomain\someuser:somepass@10.167.116.142:80
set https_proxy=http://somedomain\someuser:somepass@10.167.116.142:80
set http_proxy=http://somedomain\someuser:somepass@10.167.116.142:80
Run Code Online (Sandbox Code Playgroud)

然后我尝试克隆并获取.

$ git clone https://ProggerPete@github.com/project/JavaScript-Maven-Plugin.git
Cloning into JavaScript-Maven-Plugin...
Password:
error: The requested URL returned error: 407 while accessing https://ProggerPet
@github.com/project/JavaScript-Maven-Plugin.git/info/refs

fatal: HTTP request failed
Run Code Online (Sandbox Code Playgroud)

这对我来说就像我没有通过代理验证失败.但是,我使用相同的登录名并通过cURL传递适用于FTP.

我怎样才能连接?

Pet*_*son 29

经过多次抨击我终于偶然发现了http://cntlm.sourceforge.net/.它是一个了解ntlm身份验证的代理代理.

我安装了它并告诉它关于http代理.然后在CNTLM指向git,一切都开始工作了.

我发现让这变得非常令人沮丧,所以希望这会帮助处于相同情况的其他人.


Von*_*onC 12

我通常只需要设置:

set http_proxy=http://<login_internet>:<password_internet>@aproxy:aport
set https_proxy=http://<login_internet>:<password_internet>@aproxy:aport
Run Code Online (Sandbox Code Playgroud)

(注意https_proxy引用相同的http,而不是https,代理地址)

另请参阅" 无法让git上的Http工作 ".


jec*_*art 6

您可以将代理信息放在〜/ .curlrc中:

/home/usr/.curlrc

proxy = proxy.proxyhost.com:8443
proxy-user = user:pass
proxy-ntlm = true
noproxy = localhost,127.0.0.1,intraweb.company.com