为什么我的git代理配置不起作用?我确信我已经正确设置了它,但它仍然不起作用

sauutmhj  于 5个月前  发布在  Git
关注(0)|答案(3)|浏览(208)

我使用以下命令设置代理

$ git config --global git.proxy http://127.0.0.1:1080
$ git config --global http.proxy http://127.0.0.1:1080
$ git config --global https.proxy http://127.0.0.1:1080

字符串
但是当我克隆一个回购时,比如

# git clone [email protected]:npm/npm.git


它不使用代理来克隆。
我试着改变我的代理地址,它是随机地址。

$ git config --global git.proxy asdfi:sidfw:sfd
$ git config --global http.proxy asdfi:sidfw:sfd
$ git config --global https.proxy asdfi:sidfw:sfd


如果代理工作,git应该会提示一些错误。但是当我再次克隆时,它没有提示任何错误

$ git clone [email protected]:s97712/protobuf.js.git
Cloning into 'protobuf.js'...
Enter passphrase for key '/home/s97712/.ssh/id_rsa': 
remote: Enumerating objects: 1, done.
remote: Counting objects: 100% (1/1), done.
Receiving objects:   2% (363/18110), 60.00 KiB | 5.00 KiB/s


这意味着git代理不工作。
我还尝试使用环境变量

$ export http_proxy="http://localhost:1080"
$ export https_proxy="http://localhost:1080"


但还是不行。

ehxuflar

ehxuflar1#

git clone [email protected]:…

字符串
这是SSH协议(类似SCP的URL语法),它不使用HTTP代理。要使用代理,请将URL更改为HTTPS:

git clone https://github.com:…


PS.端口1080表明它是SOCKS代理,而不是HTTP代理。如果是,我认为代理语法不同。参见https://stackoverflow.com/a/16756248/7976758https://stackoverflow.com/search?q=%5Bgit%5D+socks+proxy

qeeaahzv

qeeaahzv2#

我通过socks5(ssh)代理服务器代理我与github.com的连接。
ssh -C -D 1080 user@host -f -Nssh socks5通过主机在后台代理,没有默认命令和压缩启用)。我的~/.ssh/config为github.com看起来像:

Host github.com
    ProxyCommand /bin/nc -X 5 -x 127.0.0.1:1080 %h %p

字符串

lskq00tm

lskq00tm3#

我在用和你一样的方法从git客户端版本1.8.x升级到2.x时也遇到了同样的问题,包括环境变量。就像你说的,什么都不起作用。
通过添加额外的git配置解决了它,如下所示

git config --global http.proxyAuthMethod 'basic'

字符串
可以确认2.x版本需要http.proxyAuthMethod配置,但1.8.x版本不需要。
希望这有帮助

相关问题