Using a socks proxy with git for the http transport

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


If you do not want to set the proxy as global config, try ALL_PROXY= e.g.:

$ ALL_PROXY=socks5://127.0.0.1:8888 git clone https://github.com/some/one.git

(Just a little reminder) If you want the hostname also be resolved by the proxy (that means passing everything through the proxy), especially when you are cloning a gist, you can use the following setting (the key is that it uses socks5h instead of socks5):

git config --global http.proxy socks5h://127.0.0.1:1080