Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using a socks proxy with git for the http transport

Tags:

git

ssh

proxy

socks

How to make git use a socks proxy for HTTP transport?

I succeed in configuring git with GIT_PROXY_COMMAND to use a socks proxy for GIT transport.

Also, I have configured my .curlrc file to defined the socks proxy and I can fetch information directly with curl command like:

curl http://git.kernel.org/pub/scm/git/git.git/info/refs?service=git-upload-pack 

But how to use a socks proxy with git to retrieve data using the HTTP transport protocol like:

git clone http://git.kernel.org/pub/scm/git 
like image 874
Yves Blusseau Avatar asked Mar 05 '13 15:03

Yves Blusseau


People also ask

What is http socks proxy?

HTTP proxies are high-level proxies usually designed for a specific protocol. While this means you get better connection speeds, they're not nearly as flexible and secure as SOCKS proxies. SOCKS proxies are low-level proxies that can handle any program or protocol and any traffic without limitations.

How do I git behind a proxy?

Setting the proxy for Git Run the following commands replacing USERNAME , PASSWORD , PROXY_ADDRESS , and PROXY_PORT with your network's information: git config --global --add http. proxy http://USERNAME:PASSWORD@PROXY_ADDRESS:PROXY_PORT. git config --global --add https.

How do I use socks proxy in terminal?

You can use http_proxy environmentvariable like this: export http_proxy="socks5://localhost:9050" Now the terminal will use that as proxy.

Does GIT use Http_proxy?

Now whenever you do anything with [email protected] , it will use the proxy automatically.


1 Answers

I tested with Git 1.8.2 and SOCKS v5 proxy, following setting works for me:

git config --global http.proxy 'socks5://127.0.0.1:7070'

UPDATE 2017-3-31:

According to the document, despite the name http.proxy, it should work for both HTTP and HTTPS repository urls. Thanks @user for pointing out this.

UPDATE 2018-11-27:

To disable the proxy, run command:

git config --global --unset http.proxy

EDIT 2019-03-04:

If you also want the host name to be resolved using the proxy, use thuzhf's solution below, which uses socks5h instead of socks5

like image 186
Yang.Y Avatar answered Sep 28 '22 06:09

Yang.Y