Git SOCKS5 Proxy: Configure HTTPS and SSH

A Git SOCKS5 proxy must match the remote transport. For HTTPS remotes, use Git's http.proxy setting with a supported SOCKS URL. For SSH remotes, configure the SSH connection separately. Start with a one-command ls-remote check before saving settings, cloning a large repository or changing a shared environment.

9Native Git local checks
3Configurations compared
9/9Expected reference returned
0Public or SSH transfers

Git sent destination names or IP addresses according to the selected SOCKS scheme.

Local Git comparison

1. Match the remote URL and configuration scope

Inspect git remote -v in an existing checkout. An https:// URL selects the HTTP transport, while git@host:path and ssh:// URLs select SSH. The name http.proxy also applies to HTTPS transfers; an HTTPS remote does not require inventing a Git https.proxy configuration key. A SOCKS listener must already exist and accept the selected connection method.

Remote transports and configuration scopes for a Git SOCKS5 proxy.
Remote or scopeConfiguration routeWhat to check
HTTPS remotehttp.proxy through Git/libcurlSOCKS support in the installed build
SSH remoteOpenSSH ProxyCommandCompatible proxy helper and host verification
One invocationgit -c setting before the subcommandNo persistent configuration change
Existing repositorygit config --local URL-specific keyRun inside the intended checkout

Use socks5h:// when the proxy should receive the destination hostname. With socks5://, the client resolves that destination first. Resolving the proxy hostname itself is separate. These settings cover this transport, not browser traffic, arbitrary DNS or every child process. The curl DNS guide explains the same URL distinction at the libcurl layer.

A URL-specific http.<url>.proxy value narrows the destination match. Git compares URL components and path prefixes; more specific matching entries can take precedence over a general http.proxy. Inspect the effective value with git config --show-origin --get-urlmatch http.proxy followed by the remote URL. Output can contain credentials, so redact it before sharing diagnostics.

2. Generate, inspect and remove a scoped setting

These POSIX shell examples generate text only. Enter an HTTPS repository URL without credentials, query parameters or fragments. The sample organization and repository are placeholders; replace them with a repository you can access. The generator supports DNS names or IPv4 proxy hosts, not IPv6 literals. It never stores secrets or runs Git in your browser.

One invocation changes no Git configuration file.

Choose a transport and configuration scope.

Your Git example will appear here.

One invocation. The -c argument belongs before ls-remote. It supplies http.proxy for that Git process without editing a file. Existing URL-specific entries may still select another route. Choose the URL-specific invocation when you need the generated setting to target this repository URL more precisely. Neither option removes bypass environment variables or overrides every possible external wrapper.

Repository persistence. The local option writes a URL-specific key in the current checkout and then checks reference discovery. It replaces existing values for that exact key. The output also includes an undo command; run it separately after testing. Removing the key does not restore an earlier value. Record any previous configuration before replacing it. No global setting is generated.

SSH helper. This branch generates an example for git@github.com:example/project.git using OpenSSH and the OpenBSD implementation of nc with -X 5 and -x. It disables the HTTPS URL and DNS controls because those do not configure this helper. Verify nc support locally; BusyBox nc, Ncat and Windows packages have different interfaces. Keep SSH host-key verification enabled.

3. Read the native Git measurements and their limits

git version 2.54.0.windows.1 performed nine ls-remote requests against a temporary bare repository containing one empty test commit. A loopback SOCKS responder recorded the CONNECT address and passed the request to a local git http-backend process. The fixture advertised refs/heads/main. Each run returned its expected object ID with exit code zero.

Nine Windows Git ls-remote runs across three SOCKS configurations.
Git configurationRoundsRecorded SOCKS addressResult
socks5h · repo.invalid3ATYP 3 · repo.invalidExpected main reference, exit 0
socks5 · localhost3ATYP 4 · ::1Expected main reference, exit 0
URL-specific proxy + invalid general proxy3ATYP 3 · repo.invalidSpecific listener used, exit 0

The remote-name runs used repo.invalid so the requested name was visible without external DNS. Local-resolution runs used localhost, whose loopback address was sent instead. The override comparison set the general proxy to port 1 and supplied the working listener in a matching URL-specific key. That comparison confirms configuration selection on this build, not every combination of system, user and command-line settings.

The target used plain HTTP only inside the local fixture. The responder generated no public exit and did not forward to an external repository. Protocol version zero and HTTP/1.1 were selected explicitly for a small, inspectable exchange. HTTPS certificates, SSH authentication, credential helpers, clone objects, push, submodules and LFS were not exercised. A successful advertisement is not evidence for those operations.

Download the complete nine-run CSV and inspect raw Git commands and SOCKS observations. The measurement source recreates the disposable fixture. Its timestamp describes this saved batch; the table has no background refresh. Rerun the measurement on another Git build before comparing its behavior.

4. Diagnose bypasses, authentication and separate clients

If no proxy connection appears, confirm the remote transport first, then inspect matching URL settings, remote-specific proxy configuration and proxy bypass variables such as NO_PROXY. A shell and an IDE can launch different Git binaries with different environments. Compare git --version and the effective configuration in each context. The Linux process guide explains why terminal settings do not automatically reach desktop applications.

A connection refusal usually means the selected listener is unavailable; a destination lookup failure may reflect the chosen DNS route. TLS errors occur after other connection stages and require checking the trust chain. Keep Git certificate verification enabled. Do not hide transport failures with http.sslVerify=false. SSH host-key errors belong to a different verification system and need separate investigation.

Repository authentication and SOCKS authentication are separate exchanges. This generator deliberately omits proxy credentials to avoid placing them in shell history, process arguments or repository configuration. Use a supported credential workflow on your client and avoid pasting token-bearing URLs into diagnostics. Even with HTTPS, a proxy can observe connection metadata such as destination and timing.

Submodules can use different URLs and Git LFS may use a separate transfer client. Test those paths individually. For SSH tunnel setup, read the dynamic forwarding guide. References: Git configuration manual and OpenBSD nc manual. These are usage references, not claims that external services were tested.

Configure browser profiles separately from Git transport.

Download RoxyBrowser

Review the official desktop profile workflow. Git proxy settings do not configure a browser profile.

Frequently Asked Questions

Does http.proxy route an SSH Git remote through SOCKS5?

No. Git uses its HTTP transport settings for HTTP and HTTPS remotes. An SSH remote uses an SSH client instead. Configure that client with a compatible ProxyCommand or a dedicated SSH host entry, and check the actual remote URL before changing proxy settings.

Should I use socks5 or socks5h for Git?

With a compatible Git/libcurl build, socks5 resolves the destination locally and socks5h passes its hostname to the SOCKS proxy. The latter changes destination name resolution for that connection. It does not tunnel every DNS request or every program on the computer.

How do I remove a repository proxy setting?

Run the generated git config --local --unset-all command inside the repository where the setting was written. It removes that exact URL-specific key. A previous value is not restored automatically, and other configuration scopes or environment variables can still provide a proxy.

Does a successful ls-remote test prove clone and push will succeed?

No. It verifies reference discovery for that request and route. Object downloads, authentication, push permissions, redirects, submodules and Git LFS may involve additional requests or separate clients. Test each required operation against a repository you are authorized to use.