Git over HTTPS uses the http.proxy setting (or the https_proxy environment variable) and accepts http://, socks5:// and socks5h:// proxy URLs. Git over SSH ignores both and needs a ProxyCommand in ~/.ssh/config. If a clone is slow, find out where the time goes before changing settings. This article describes behavior as of November 2026.
How do I make git use a proxy for HTTPS remotes?
Set http.proxy with git config. Despite the name, git hands HTTPS requests to libcurl, and the same setting covers both http:// and https:// remotes. You can also set the proxy for a single shell session with an environment variable instead of touching your config file.
git config --global http.proxy http://proxy.example.com:8080
git config --global --get http.proxy
# or, for the current shell only
export https_proxy=http://proxy.example.com:8080
git clone https://github.com/example/repo.git
If the proxy needs credentials, put them in the URL: http://user:password@proxy.example.com:8080. Percent-encode special characters in the password (for example @ becomes %40), and remember that ~/.gitconfig is a plain-text file. Prefer lowercase variable names such as https_proxy and no_proxy; they are read by every curl-based tool.
Git does not read the proxy panel of your browser or operating system. If a page opens in the browser but git clone hangs, that is the first thing to check.
Should I use socks5 or socks5h with git?
Use socks5h:// when you want the proxy to resolve the hostname for you. With socks5://, your machine resolves the name locally and sends only an IP address to the proxy, which fails when local DNS is wrong or blocked. HTTP proxies always receive the hostname.
git config --global http.proxy socks5h://user:password@proxy.example.com:1080
The scheme must match the protocol that the port actually speaks. Pointing an http:// URL at a SOCKS port, or the other way around, is the most common cause of "Failed to connect" and "Proxy CONNECT aborted" style errors.
How do I proxy only one host, or switch the proxy off?
Git lets you attach http.proxy to a URL prefix, so only matching remotes use it. An empty value disables the proxy for that prefix, which is useful for an internal server that should be reached directly.
git config --global http.https://github.com.proxy http://proxy.example.com:8080
git config --global http.https://git.internal.example.com.proxy ""
# remove the global setting
git config --global --unset http.proxy
# list everything proxy-related that git can see
git config --show-origin --get-regexp proxy
Environment variables work too: no_proxy=git.internal.example.com keeps one host off the proxy. Check git config --show-origin when behavior surprises you, because system, global and repository-level files all apply.
How do I send git over SSH through a proxy?
SSH remotes such as git@github.com:example/repo.git do not use http.proxy. Tell OpenSSH how to reach the server with ProxyCommand. The example below uses the OpenBSD flavor of netcat, where -X 5 selects SOCKS5 (use -X connect for an HTTP proxy) and -x gives the proxy address.
Host github.com
ProxyCommand nc -X 5 -x proxy.example.com:1080 %h %p
Other netcat builds use different flags, and on Windows you would use a helper such as the connect tool shipped with Git for Windows; check its usage text. Passing a proxy password through nc is awkward, so a proxy that authorizes by source IP is easier here. If you only need to get around a blocked port 22, switching the remote to its HTTPS URL is often simpler than configuring SSH at all.
Why is my git clone slow, and how do I find out?
A slow clone has a handful of usual causes: the proxy is not actually used, DNS is slow, the repository history is large, or a protocol hiccup stalls the transfer. Work through them in order, starting with the cheapest check. Measure first; every change below is reversible.
- Confirm the path. Run
GIT_CURL_VERBOSE=1 git clone https://github.com/example/repo.gitand look at the connection lines. They should name your proxy host, not the remote server. - Compare with curl.
curl -x http://proxy.example.com:8080 -I https://github.comuses the same library. If curl is also slow, the problem is the network path, not git. - Fetch less.
git clone --depth 1 --single-branch URLdownloads one commit.git clone --filter=blob:none URLskips file contents until you need them.git fetch --unshallowrestores full history later. - Try HTTP/1.1.
git -c http.version=HTTP/1.1 clone URLworks around stalls that occur in the middle of "Receiving objects". - Fail fast. Set
http.lowSpeedLimitandhttp.lowSpeedTimeso git aborts a transfer that stays below a threshold instead of hanging forever.
| Symptom | Likely cause | What to try |
|---|---|---|
| Hangs before any output | Proxy unreachable, or slow DNS | Test with curl; try socks5h:// |
| Received HTTP code 407 from proxy | Missing or wrong credentials | Check URL encoding of the password |
| Failed to connect to proxy | Wrong host, port or scheme | Match http:// or socks5h:// to the port |
| Starts fast, stalls while receiving objects | Large history or HTTP/2 stall | Shallow or partial clone; HTTP/1.1 |
| Works in a browser only | Git ignores OS proxy settings | Set http.proxy |
Where AnboVPN fits
AnboVPN's HTTP/SOCKS5 proxy gives you an exclusive IP that speaks both HTTP (including HTTPS tunnels) and SOCKS5, with one set of username and password, so either URL form above works. You can also set a source-IP allowlist so your machine does not need a password in ~/.gitconfig. Usage counts against your data plan and the proxy stops when the plan runs out, so shallow and partial clones are worth using. See the HTTP/SOCKS5 proxy page.
