Change language
English Русский Deutsch Español Français Italiano Українська Tiếng Việt Türkçe Bahasa Indonesia हिन्दी 日本語 Português 中文
Menu
Pricing
Proxies
Solutions
Resources

How to configure a proxy in Git

Topic: Setup by device and app All answers

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:...) ignore http.proxy.
  • A 407 from git clone means 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.

Quick answers about Git and proxies

Does the proxy apply to git@ remotes?

No. http.proxy affects http and https remotes. A git@ remote runs over SSH, which has its own proxy setting.

How do I use the proxy for one host only?

Add the host to the key: git config --global http.https://example.com.proxy http://HOST:PORT, with your own host in place of example.com.

How do I see what Git sends?

Run the command with GIT_CURL_VERBOSE=1 in front. The output shows the CONNECT request to your proxy.

Related pages