解决方案:
1.终端输入:ifconfig -a |grep inet,找到自己的IP地址(inet后面的内容)
2.通过站长工具(https://tool.chinaz.com/)查询到可用的github的dns
3.打开终端命令行,输入命令:sudo gedit /etc/hosts
即打开hosts文件,修改里面的内容如下
127.0.0.1 localhost
127.0.1.1 mylinux #这是用户名,不同的电脑显示不一样
在此处后面添加:
xxx.xxx.xxx.xxx github.com git(x是步骤1找到的自己的IP地址)
yyy.yyy.yyy.yyy github.com(y是步骤2找到的github的dns)
再在后面添加如下代码:
github.com
192.30.253.112 github.com
192.30.253.119 gist.github.com
151.101.100.133 assets-cdn.github.com
151.101.100.133 raw.githubusercontent.com
151.101.100.133 gist.githubusercontent.com
151.101.100.133 cloud.githubusercontent.com
151.101.100.133 camo.githubusercontent.com
151.101.100.133 avatars0.githubusercontent.com
151.101.100.133 avatars1.githubusercontent.com
151.101.100.133 avatars2.githubusercontent.com
151.101.100.133 avatars3.githubusercontent.com
151.101.100.133 avatars4.githubusercontent.com
151.101.100.133 avatars5.githubusercontent.com
151.101.100.133 avatars6.githubusercontent.com
151.101.100.133 avatars7.githubusercontent.com
151.101.100.133 avatars8.githubusercontent.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
151.101.113.194 github.global.ssl.fastly.net
The following lines are desirable for IPv6 capable hosts
::1 ip6-localhost ip6-loopback
fe00::0 ip6-localnet
ff00::0 ip6-mcastprefix
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters
参考博客:
https://blog.51cto.com/u_15242250/2856080
https://blog.csdn.net/voshv/article/details/127120400