Getting Git to work with a proxy server - fails with “Request timed out”

前端 未结 19 2893
旧时难觅i
旧时难觅i 2020-11-22 05:09

How do I get Git to use a proxy server?

I need to check out code from a Git server, but it shows \"Request timed out\" every time. How do I get around this?

19条回答
  •  佛祖请我去吃肉
    2020-11-22 05:25

    Setting git proxy on terminal

    if

    • you do not want set proxy for each of your git projects manually, one by one
    • always want to use same proxy for all your projects

    Set it globally once

    git config --global http.proxy username:password@proxy_url:proxy_port
    git config --global https.proxy username:password@proxy_url:proxy_port
    

    if you want to set proxy for only one git project (there may be some situations where you may not want to use same proxy or any proxy at all for some git connections)

    //go to project root
    cd /bla_bla/project_root
    //set proxy for both http and https
    git config http.proxy username:password@proxy_url:proxy_port
    git config https.proxy username:password@proxy_url:proxy_port
    

    if you want to display current proxy settings

    git config --list 
    

    if you want to remove proxy globally

    git config --global --unset http.proxy
    git config --global --unset https.proxy
    

    if you want to remove proxy for only one git root

    //go to project root
    cd /bla-bla/project_root
    git config --unset http.proxy
    git config --unset https.proxy
    

提交回复
热议问题