背景

国内同步github上的项目速度过慢,可以通过设置代理提高速度

解决方案

  • 查看代理配置

    1
    2
    git config --global --get http.proxy
    git config --global --get https.proxy
  • 设置全局代理

    1
    2
    3
    4
    5
    git config --global http.proxy 'socks5://127.0.0.1:1080'
    git config --global https.proxy 'socks5://127.0.0.1:1080'

    git config --global http.proxy 'http://127.0.0.1:1080'
    git config --global https.proxy 'http://127.0.0.1:1080'
  • 取消全局代理

    1
    2
    git config --global --unset http.proxy
    git config --global --unset https.proxy
  • 针对指定域名或者IP,例如https://github.com

    1
    2
    3
    4
    5
    6
    # 设置
    git config --global http.https://github.com.proxy socks5://127.0.0.1:1080
    # 查看
    git config --global --get http.https://github.com.proxy
    # 取消
    git config --global --unset http.https://github.com.proxy
  • git clone 命令行http代理设置, 例如

    1
    git clone -c  http.proxy=http://127.0.0.1:1080/  https://github.com/user/path