在git 中 git pull、git init、git clone 时报错 could not resolve host: github.com

详细报错信息:

fatal: unable to access 'https://github.com/*****.git/': Could not resolve host: github.com

错误的原因: github.com 的域名没有被主机解析。

解决方案:

  1. 使用命令:ping 域名地址,解析域名对应的IP地址。
    在命令行中输入$ ping github.com
    PING github.com (13.229.188.59) 56(84) bytes of data.
    12

从上图可知,解析得到的github的域名IP地址为:13.229.188.59

  1. 把域名和IP地址添加到电脑主机的hosts配置文件中。
host配置文件的地址:C:\Windows\System32\drivers\etc

然后把13.229.188.59 github.com 添加到hosts文件中保存退出即可。

猜你喜欢

转载自blog.csdn.net/weixin_40599109/article/details/108445079