git clone速度太慢的解决办法

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

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

[[325366]]

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

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

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

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

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

如下图:

然后修改hosts文件

Windows上的hosts文件路径在

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

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

sudo vim /etc/hosts

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

sudo vi /etc/hosts

在hosts文件末尾添加两行

github.com 13.229.188.59

github.global.ssl.fastly.Net 151.101.229.194

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公社
相关推荐

2023-09-02 20:13:01

代码网速

2009-01-14 09:16:24

SQL Server查SQL Server查SQL Server

2009-06-03 16:41:21

Eclipse乱码Eclipse

2011-03-04 13:07:47

Filezilla

2011-01-19 17:54:48

2009-05-31 09:07:35

Oracle锁定

2011-06-17 11:10:51

Qt 中文 输出

2009-12-07 18:38:16

WCF异常

2010-01-15 09:38:08

磁盘被写保护解决办法

2017-05-04 20:15:51

iOSNSTimer循环引用

2009-02-18 09:30:10

AJAX跨域XML

2012-03-14 10:58:27

Java

2009-05-26 14:34:55

Ubuntuwubi临时

2009-12-03 17:36:02

PHP Date()出

2012-07-31 16:06:28

Linux内核编译

2009-11-30 10:55:16

PHP页面乱码

2011-04-21 16:42:40

传真机

2012-12-12 15:19:32

云安全

2009-08-31 08:35:54

Windows 7系统蓝屏

2010-04-19 14:57:16

Oracle收缩表分区
点赞
收藏

51CTO技术栈公众号