我使用以下命令设置代理
$ 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"
型
但还是不行。
3条答案
按热度按时间ehxuflar1#
字符串
这是SSH协议(类似SCP的URL语法),它不使用HTTP代理。要使用代理,请将URL更改为HTTPS:
型
PS.端口1080表明它是SOCKS代理,而不是HTTP代理。如果是,我认为代理语法不同。参见https://stackoverflow.com/a/16756248/7976758和https://stackoverflow.com/search?q=%5Bgit%5D+socks+proxy。
qeeaahzv2#
我通过socks5(
ssh
)代理服务器代理我与github.com的连接。即
ssh -C -D 1080 user@host -f -N
(ssh
socks5通过主机在后台代理,没有默认命令和压缩启用)。我的~/.ssh/config
为github.com看起来像:字符串
lskq00tm3#
我在用和你一样的方法从git客户端版本1.8.x升级到2.x时也遇到了同样的问题,包括环境变量。就像你说的,什么都不起作用。
通过添加额外的git配置解决了它,如下所示
字符串
可以确认2.x版本需要
http.proxyAuthMethod
配置,但1.8.x版本不需要。希望这有帮助