Git 配置代理无效

2024-01-22 21:26:41 +08:00
qviqvi  qviqvi

如果本地有 http 和 socks5 代理,命令行启动的。其他软件指定走代理,有效,但 git 配置代理仍然无效,命令行客户端也不打印日志,很奇怪

但如果用火箭这种图形界面的客户端启动代理,git 就成功走代理了

目前试过下面的配置均无效

git config --global http.proxy 'http://127.0.0.1:1087'
git config --global https.proxy 'http://127.0.0.1:1087'

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

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

暂时通过改 hosts 或者图形界面客户端可以解决,但不明白为什么无效

2507 次点击
所在节点   程序员  程序员
13 条回复
skiy
skiy
2024-01-22 21:35:52 +08:00
直接 https_proxy=http://127.0.0.1:1087 git clone xxxx 这样就行了,没必要使用 git 就全部走全局啊。

如果是 linux ,推荐使用 proxychains 这个工具,非常好用。
Nosub
Nosub
2024-01-22 21:36:06 +08:00
浏览器可以打开 github 吗。
mschultz
mschultz
2024-01-22 21:43:02 +08:00
你的 git 操作访问的是 HTTPS 协议站点还是走 SSH 协议?走 SSH 的话上面的代理设置确实会无效(全都是 http 设置)。

另外站内早有这个问题的详细解决方案了,考虑了各种情况,描述很清楚,推荐阅读。https://www.v2ex.com/t/843383
CEBBCAT
CEBBCAT
2024-01-22 21:44:30 +08:00
排查下 DNS 问题
Nazz
Nazz
2024-01-22 21:45:05 +08:00
要配 ssh 代理而不是 https
LL77
LL77
2024-01-23 09:00:31 +08:00
不是 git 配代理,是给终端配代理,export http_proxy=xxx && export https_proxy=xxx
defunct9
defunct9
2024-01-23 10:55:39 +08:00
my3157
my3157
2024-01-23 10:58:16 +08:00
如果是 ssh 协议, .ssh/config 添加

Host github.com
HostName github.com
Port 22
User git
ProxyCommand nc -X 5 -x socks5-host: socks5-port %h %p

如果是 http 协议,设置 http proxy env
clhlc
clhlc
2024-01-23 10:59:43 +08:00
编辑~/.ssh/config 加入

Host github.com
HostName github.com
Port 22
User git
ProxyCommand nc -X 5 -x 127.0.0.1:7890 %h %p
eaststarpen
eaststarpen
2024-01-23 11:29:16 +08:00
https://hellodk.cn/post/975

推荐这个帖子,比较系统
iphoneXr
iphoneXr
2024-01-23 15:10:19 +08:00
export ALL_PROXY=socks5://127.0.0.1:1080 #可以加速 git clone 下载速度
sead
sead
2024-01-23 15:18:37 +08:00
~/.gitconfig
[http]
proxy = http://127.0.0.1:1087
[https]
proxy = http://127.0.0.1:1087
elboble
elboble
2024-01-24 09:08:32 +08:00
git 都是用 ssh 的了,所有 htttp ,https 的 proxy 都不管用了

.ssh/config 里加配置可破

https://stackoverflow.com/questions/19161960/connect-with-ssh-through-a-proxy#:~:text=ProxyCommand%20ncat%20%2D%2Dproxy

这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。

https://www.v2ex.com/t/1010767

V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。

V2EX is a community of developers, designers and creative people.

© 2021 V2EX