github无法访问克隆不了项目下载失败没反映的解决方法

当我们克隆github上的项目时,有时因为DNS的问题,基本上克隆不了,一直卡在Clone into 'go'...,如下图所示:

jagitch@34c4dd4d4a3e:opensource$ git clone https://github.com/golang/go.git
Cloning into 'go'...

解决方法:

  1. 查询github.com的ip地址,如下图所示,github.com的ip为对20.205.243.166

    在这里插入图片描述

  2. 将上一步查询到的github.com的IP配置到/etc/hosts文件中,如果是Windows系统,则修改C:\Windows\System32\drivers\etc\hosts文件

    127.0.0.1       localhost
    ::1     localhost ip6-localhost ip6-loopback
    fe00::0 ip6-localnet
    ff00::0 ip6-mcastprefix
    ff02::1 ip6-allnodes
    ff02::2 ip6-allrouters
    172.18.0.2      34c4dd4d4a3e
    
    20.205.243.166  github.com
    
  3. 再次克隆项目,即可发现可以已经可以克隆,且网速还挺快的

    jagitch@34c4dd4d4a3e:opensource$ git clone https://github.com/golang/go.git
    Cloning into 'go'...
    remote: Enumerating objects: 615933, done.
    remote: Counting objects: 100% (22992/22992), done.
    remote: Compressing objects: 100% (846/846), done.
    Receiving objects:  97% (602909/615933), 320.30 MiB | 2.73 MiB/s
    

注意:

github的IP可能会变化,当github访问不了的时候再查询最新的IP配置到/etc/hosts即可

  • 8
    点赞
  • 7
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

gopyer

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值