git clone 出现错误 Could not resolve host: github.com
一、错误原因
git clone 从github上克隆项目的时候出现这个错误,下面我贴出详细的错误信息
mosheng@ms-server:11_DSPR$ git clone https://github.com/cszn/DPSR.git
Cloning into 'DPSR'...
fatal: unable to access 'https://github.com/cszn/DPSR.git/': Could not resolve host: github.com
这个错误的原因可能是github.com
域名没有被主机解析,下面给出具体的解决方法:
二、解决方法
1、解析出域名对应的IP地址
命令:ping 域名地址
mosheng@ms-server:11_DSPR$ ping github.com
PING github.com (13.229.188.59) 56(84) bytes of data.
从上面可以看到,解析出的github的域名的IP地址为:13.229.188.59
2、把域名和IP地址添加到主机的hosts配置文件中
host配置文件的地址:/etc/host
vi /etc/hosts
然后把13.229.188.59 github.com
添加到对应的下方,之后保存退出即可
最后在克隆一下试试吧,应该是惊喜把!!!
♠ ⊕ ♠ ⊕ ♠ ⊕ ♠ ⊕ ♠ ⊕ ♠ ⊕ ♠ ⊕ ♠ ⊕ ♠ ⊕ ♠ ⊕ ♠ ⊕ ♠ ⊕ ♠ ⊕ ♠ ⊕ ♠ ⊕ ♠ ⊕ ♠ ⊕ ♠ ⊕ ♠ ⊕ ♠ ⊕ ♠ ⊕ ♠ ⊕ ♠ ⊕ ♠ ⊕ ♠ ⊕ ♠ ⊕ ♠ ⊕ ♠ ⊕ ♠ ⊕ ♠ ⊕ ♠