Set Git Proxy

Set Git Proxy

Git Proxy

HTTP & HTTPS

修改 ~/.gitconfig 即可

INI
[https]    proxy = http://127.0.0.1:7890[http]    proxy = http://127.0.0.1:7890# 如果只想让 github 走代理,可以在 `~/.gitconfig` 中这样设置[http "https://github.com"]    proxy = http://127.0.0.1:7890[https "https://github.com"]    proxy = http://127.0.0.1:7890

SSH

修改 ~/.ssh/config,添加 ProxyCommand 配置项走代理即可

Proxy Port

SSH 代理通常需要使用 SOCKS5 端口,无法通过普通 HTTP 代理端口转发。

因个人在 Clash Verge Rev 中启用了混合端口(Mixed Port),这里在 ProxyCommand 使用的仍为 127.0.0.1:7890,它同时支持 HTTP 和 SOCKS5 协议。相关介绍参考代理端口 - 虚空终端 Docs

Windows Example

SSH-CONFIG
Host github.com  User git  Hostname ssh.github.com  Port 443  IdentityFile "~/.ssh/id_rsa"  TCPKeepAlive yes  ProxyCommand "D:\envir_vars\scoop\apps\git\current\mingw64\bin\connect.exe" -S 127.0.0.1:7890 %h %p

Mac Example

SSH-CONFIG
Host github.com  User git  Hostname ssh.github.com  Port 443  IdentityFile "~/.ssh/id_rsa"  TCPKeepAlive yes  ProxyCommand nc -X 5 -x 127.0.0.1:7890 %h %p
作者

GnixAij

发布于

2025-05-30

更新于

2025-08-12

许可协议

评论