Skip to main content

13 Git proxy config

1. Alternative 1 to proxy via ssh for git.

Config the ~/.ssh/config file, add the following config:

Host github.com # <-- The name of the host you want to connect to like github.com
Hostname github.com # <-- The actual hostname of the server like github.com
User git
ProxyCommand nc -x <proxy_server>:<proxy_port> -X 5 %h %p # Set the proxy server and port

If you want to cancel the proxy, you just need to remove the above config.

2. Alternative 2 to proxy via bash environment variable.

   git config --global http.proxy <proxy_server>:<proxy_port>
git config --global https.proxy <proxy_server>:<proxy_port>

If you want to cancel the proxy, The following command can be used:

   git config --global --unset http.proxy
git config --global --unset https.proxy