手机版
你好,游客 登录 注册
背景:
阅读新闻

git clone速度太慢的解决办法(亲测还有效)

[日期:2019-05-04] 来源:Linux公社  作者:醉落红尘 [字体: ]

在国内,你们肯定发现使用git clone的速度实在太慢,git clone的速度可能会让你难以承受,现再次整理解决方法与大家分享,有图有真相。

git clone速度太慢的解决办法(亲测还有效)

原因:git clone特别慢是因为github.global.ssl.fastly.net域名被限制了。只要找到这个域名对应的ip地址,然后在hosts文件中加上ip–>域名的映射,刷新DNS缓存便可。

适用各种操作系统,本次测试系统为Ubuntu 18.04.2 LTS,下载速度从几k提高到1M多。

git clone速度太慢的解决办法(亲测还有效)

没有修改前git clone速度实在慢只有10K左右,如上图。

修改后,git clone速度达到800多k。或者1M多。

git clone速度太慢的解决办法(亲测还有效)

1、查找域名对应的ip地址,并修改hosts文件

linuxidc@linuxidc:~/linuxidc.com$ nslookup github.global.ssl.fastly.Net
Server:  127.0.0.53
Address: 127.0.0.53#53

Non-authoritative answer:
Name: github.global.ssl.fastly.Net
Address: 151.101.229.194

linuxidc@linuxidc:~/linuxidc.com$ nslookup github.com
Server:  127.0.0.53
Address: 127.0.0.53#53

Non-authoritative answer:
Name: github.com
Address: 13.229.188.59

如下图:

git clone速度太慢的解决办法(亲测还有效)

然后修改hosts文件

Windows上的hosts文件路径在

C:\Windows\System32\drivers\etc\hosts

Linux的hosts文件路径在/etc/hosts中

sudo vim /etc/hosts

git clone速度太慢的解决办法(亲测还有效)

Mac的hosts文件路径也在/etc/hosts中

sudo vi /etc/hosts

在hosts文件末尾添加两行

github.com 13.229.188.59
github.global.ssl.fastly.Net 151.101.229.194

git clone速度太慢的解决办法(亲测还有效)

2、刷新DNS缓存

Linux:

sudo /etc/init.d/networking restart

Windows

ipconfig /flushdns

Mac

sudo killall -HUP mDNSResponder

以前的文章:git clone下载速度特慢的解决方案 https://www.linuxidc.com/Linux/2017-10/148116.htm

Linux公社的RSS地址https://www.linuxidc.com/rssFeed.aspx

本文永久更新链接地址https://www.linuxidc.com/Linux/2019-05/158461.htm

linux
相关资讯       Git clone  git clone速度慢  git clone速 
本文评论   查看全部评论 (0)
表情: 表情 姓名: 字数

       

评论声明
  • 尊重网上道德,遵守中华人民共和国的各项有关法律法规
  • 承担一切因您的行为而直接或间接导致的民事或刑事法律责任
  • 本站管理人员有权保留或删除其管辖留言中的任意内容
  • 本站有权在网站内转载或引用您的评论
  • 参与本评论即表明您已经阅读并接受上述条款