How to configure a proxy in Git
In short: Run git config –global http.proxy http://LOGIN:PASSWORD@HOST:PORT to send Git over an HTTP proxy, or use socks5h://HOST:PORT for SOCKS5. It covers http and https remotes only, not SSH ones. Remove it with git config –global –unset http.proxy. The credentials land in your Git config file in plain text.
Git talks to http and https remotes through libcurl, so it follows the same proxy rules as curl. Take the host, port, login and password from one row in My Proxies in your dashboard.
Set it for all your repositories
git config --global http.proxy http://LOGIN:PASSWORD@HOST:PORT
This writes one line into ~/.gitconfig. One setting covers both http and https remotes.
Check it with git config --get http.proxy.
For a SOCKS5 order, switch it with Change protocol, copy the details again and use:
git config --global http.proxy socks5h://LOGIN:PASSWORD@HOST:PORT
The h makes the proxy resolve host names. See the SOCKS5 proxies
page for the protocol.
Encode special characters
The login sits inside a URL, so @ must be written %40, : as %3A, / as %2F, #
as %23 and % as %25. An unencoded password is cut short and the proxy answers 407.
One repository or one host
Drop --global inside a repository to set it for that repository only:
git config http.proxy http://LOGIN:PASSWORD@HOST:PORT
To limit the proxy to one host, put the host into the key:
git config --global http.https://example.com.proxy http://LOGIN:PASSWORD@HOST:PORT
Environment variables
Git also reads http_proxy, https_proxy and all_proxy from the shell, and the no_proxy
list of hosts to skip. The config key, when set, takes priority over them.
Which scope to use
A global setting is the simplest, but it sends every http and https remote through the
proxy, including internal servers that the proxy cannot reach. If you hit that, scope the
proxy to a host or a repository, or list internal hosts in no_proxy. A per-host key is the
safest choice when only one remote needs the proxy.
Remove it
git config --global --unset http.proxy
Things to know
- The password is stored in plain text in your Git config file. Keep that file private and do not commit it.
- SSH remotes (
git@host:...) ignorehttp.proxy. - A 407 from
git clonemeans the proxy rejected the login: proxy error 407 lists the checks, and proxy authentication failed covers allowlist mode. - Use the proxy only for repositories you may access, as the Acceptable Use Policy requires. Plans are on the ISP proxies page.
