github访问慢的解决方法

一、设置全局代理

  1. 设置http协议

    git config --global http.proxy http://127.0.0.1:47988
    git config --global https.proxy https://127.0.0.1:47988

    使用上面的命令配置完之后,会在 ~/.gitconfig 文件中多出几行:

    [http]
    proxy = http://127.0.0.1:47988
    [https]
    proxy = http://127.0.0.1:47988
  2. 设置socks5协议

    git config --global http.proxy  socks5://127.0.0.1:53127
    git config --global https.proxy  socks5://127.0.0.1:53127

    使用上面的命令配置完之后,会在 ~/.gitconfig 文件中多出几行:

    [http]
    proxy = socks5://127.0.0.1:53127
    [https]
    proxy = socks5://127.0.0.1:53127
  3. 请注意,这里指的是http/https协议,也就是git clone https://www.github.com/xxxx/xxxx.git,这种对于SSH协议,也就是git clone git@github.com:xxxxxx/xxxxxx.git依旧是无效的

  4. 检查配置是否生效:

    git config --global --get http.proxy
    git config --global --get https.proxy
  5. 取消该设置方法:

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

二、设置部分代理

但我不推荐直接用全局代理,因为如果挂了全局代理,这样如果需要克隆coding之类的国内仓库,会奇慢无比!所以我建议使用这条命令,只对github进行代理,对国内的仓库不影响。

  1. 设置http协议

    git config --global http.http://github.com.proxy http://127.0.0.1:47988
    git config --global https.https://github.com.proxy https://127.0.0.1:47988
  2. 设置socks5协议

    git config --global http.http://github.com.proxy socks5://127.0.0.1:53127
    git config --global https.https://github.com.proxy socks5://127.0.0.1:53127
  3. 同时,如果在输入这条命令之前,已经输入全局代理的话,可以输入下面的命令进行取消

    git config --global --unset http.http://github.com.proxy
    git config --global --unset https.https://github.com.proxy
  4. 检查配置是否生效:

    git config --global --get http.http://github.com.proxy
    git config --global --get https.https://github.com.proxy
  5. 取消该设置方法:

    git config --global --unset http.http://github.com.proxy
    git config --global --unset https.https://github.com.proxy
  • 1
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值