placeholderSet Git Proxy

Set Git Proxy

Set up a proxy for Git operations, both for HTTP/HTTPS and SSH connections.

Git Proxy

HTTP & HTTPS

When your proxy tool provides an HTTP proxy service on port 7890, you can add the following configuration to ~/.gitconfig so Git’s HTTP and HTTPS requests go through the proxy.

[https]    proxy = http://127.0.0.1:7890[http]    proxy = http://127.0.0.1:7890

If you only want GitHub traffic to use the proxy, add the following configuration to ~/.gitconfig.

[http "https://github.com"]    proxy = http://127.0.0.1:7890[https "https://github.com"]    proxy = http://127.0.0.1:7890

SSH

Edit ~/.ssh/config and add a ProxyCommand entry to route SSH through the proxy.

Proxy Port

SSH proxies usually need a SOCKS5 port and cannot be forwarded through a regular HTTP proxy port.

Because I enabled the mixed port in Clash Verge Rev, the ProxyCommand here still uses 127.0.0.1:7890; it supports both HTTP and SOCKS5. See Proxy Port - Void Terminal Docs for the related explanation.

Windows Example

Git for Windows includes connect.exe, which can be used for proxy forwarding. I installed Git with Scoop, so my connect.exe path is D:\envir_vars\scoop\apps\git\current\mingw64\bin\connect.exe. Adjust it to match your actual path.

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

On macOS, you can use the system-provided nc for proxy forwarding.

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