如何提升git clone的速度

一、有代理

在你的代理软件高级设置中,有 socket5 代理端口,下面的命令中的端口用的你软件中的端口。

https 方式 clone 代码

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

根据你本地软件不同,socks5 的端口不同,修改对应端口

ssh 方式 clone 代码

修改本机的 ~/.ssh/config,给里面添加一条记录。

Host github.com
  ProxyCommand nc -v -x 127.0.0.1:1086 %h %p

二、没代理

1、在网站ipaddress.com 分别搜索:

github.global.ssl.fastly.net
github.com

得到ip:

  1. 修改hosts文件
    windows目录在 C:WindowsSystem32driversetchosts
    mac/linux目录在:/etc/hosts 在此文件后面加如下内容
// ip以你得到的ip为准

199.232.69.194 github.global-ssl.fastly.net
140.82.114.3 github.com 

注意: 使用的时候根据配置的clone方式来选择ssh还是https

原文地址:https://www.cnblogs.com/zongfa/p/14285307.html