blog icon indicating copy to clipboard operation
blog copied to clipboard

git clone 下载提速

Open Godiswill opened this issue 5 years ago • 0 comments

git clone 下载提速

git clone https://github.com/facebook/react.git

发现克隆仓库时,特别慢,10kb/s 徘徊。后来用 best trace 追踪以下域名。

github.com
assets-cdn.github.com
github.global.ssl.fastly.net

结果发现 github.global.ssl.fastly.netIP 与在 IPAddress 查出的 IP 不一致。说明 DNS 被东方的神秘力量污染了。

解决办法修改 hosts 文件,直接 IP 与 域名映射。 以 mac 为例

sudo vi /etc/hosts
  • hosts 文件追加
140.82.113.3	github.com
# 185.199.108.153	assets-cdn.github.com
# 185.199.109.153	assets-cdn.github.com
# 185.199.110.153	assets-cdn.github.com
185.199.111.153	assets-cdn.github.com
199.232.5.194	github.global.ssl.fastly.net
  • IPAddress 查出 assets-cdn.github.com 有多个 IP,可以简单 ping 一下 找出最快的,例如 185.199.111.153 本人测试延迟最少。 如果 IP 被封网速变慢,重复一下操作。

结果 git clone 速度显著提升。

Godiswill avatar Jan 19 '20 02:01 Godiswill