git clone 时报错,提示 ssh: Could not resolve hostname github.com: Name or service not known

时间:2024-03-23 21:35:12

git clone 时报错,提示 ssh: Could not resolve hostname github.com: Name or service not known
在git clone克隆仓库代码时,提示 ssh: Could not resolve hostname github.com: Name or service not known

百度后,解决方法如下:

  1. ping github.com
    获取到github.com的ip为13.xxx.xxx.xxx
    git clone 时报错,提示 ssh: Could not resolve hostname github.com: Name or service not known
  2. 在/etc/hosts中添加一行如下:
    此文件的路径如下:
    git clone 时报错,提示 ssh: Could not resolve hostname github.com: Name or service not known
    右击hosts文件,并以记事本格式打开。然后在文件最后一行添加如下内容:
    13.xxx.xxx.xxx github.com

此时,在进行git clone xxx时,就可以进入到输入码云账户及密码的步骤了。