步骤一:得到ip
在下列网站上 https://www.ipaddress.com/ 分别搜索:
github.global.ssl.fastly.net
github.com
然后记录得到的IP地址
步骤二: 修改host
在Windows中,先进入:C:\Windows\System32\drivers\etc 目录
然后右键hosts文件,使用文件编译器打开,我这里使用的是Sublime Text,也可以使用Notepad++等其它文本编辑器
在文件中添加这两行
151.101.1.194 github.global-ssl.fastly.net
140.82.112.3 github.com
注意:上边的ip要替换成你自己搜索出来的
然后ctrl s 保存
扩展一:如果host无法保存
如果提示下列错误
这里参考这篇文章,修改hosts文件的权限
https://blog.csdn.net/WZH577/article/details/115386190
然后ctrl s 就可以保存了
本文的主要参考文章:
https://zhuanlan.zhihu.com/p/58006202
扩展二:使用代理时的配置
使用代理时,如果遇到下列错误
在命令行中加入:
git config --global http.proxy 'socks5h://127.0.0.1:7890'
git config --global https.proxy 'socks5h://127.0.0.1:7890'
git config --global http.proxy 'socks5h://127.0.0.1:1080'
git config --global https.proxy 'socks5h://127.0.0.1:1080'
git config --global http.proxy 'socks5h://127.0.0.1:1086'
git config --global https.proxy 'socks5h://127.0.0.1:1086'
这三个执行一个就可以,一个不好用,就试试另一个,取决于你的代理用的哪个端口