Using a socks proxy with git for the http transport

前端 未结 7 1861
臣服心动
臣服心动 2020-11-28 00:48

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 hav

相关标签:
7条回答
  • 2020-11-28 01:13

    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

    0 讨论(0)
  • 2020-11-28 01:16

    I use the following command to clone a specific repository from socks5 proxy. The proxy settings are specified with --config option.

    $ git clone https://github.com/xxxxx --config 'http.proxy=socks5://127.0.0.1:1234'
    
    0 讨论(0)
  • 2020-11-28 01:16

    None of the suggested methods worked for me, so I found another approach as the following instruction:


    1. Make a tunnel (dynamic port forwarding) over SOCKS5 protocol using ssh:
      ssh -ND 9994 user@YourSshServer

    1. Install proxychains on your localhost, not the ssh server you're connected to:
    • Using apt-get:
      sudo apt-get install proxychains
    • Using its GitHub repository:
      Check Installation section on its readme file.
      How to set socks5 proxy on firefox

    1. Edit your proxychains configure file:
      sudo nano /etc/proxychains.conf then add the following line at the end of file:
      socks5 127.0.0.1 9994

    1. Now we are ready to do a git command (proxychains must be placed before the command):
      proxychains git push origin develop
    0 讨论(0)
  • 2020-11-28 01:20

    (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
    
    0 讨论(0)
  • 2020-11-28 01:24

    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
    
    0 讨论(0)
  • 2020-11-28 01:24

    Just in reference to @briankip and removing the http proxy setting as Yang.Y mentioned you can directly edit the ini file.

    You can also do this on the command line using

    git config --global --unset http.proxy

    To confirm it has been removed list the current configuration using

    git config --list

    0 讨论(0)
提交回复
热议问题