当我们克隆github
上的项目时,有时因为DNS的问题,基本上克隆不了,一直卡在Clone into 'go'...
,如下图所示:
jagitch@34c4dd4d4a3e:opensource$ git clone https://github.com/golang/go.git
Cloning into 'go'...
- 1
- 2
解决方法:
-
查询github.com的ip地址,如下图所示,github.com的ip为对
20.205.243.166
-
将上一步查询到的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
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
-
再次克隆项目,即可发现可以已经可以克隆,且网速还挺快的
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
- 1
- 2
- 3
- 4
- 5
- 6
注意:
github
的IP可能会变化,当github
访问不了的时候再查询最新的IP配置到/etc/hosts
即可
评论记录:
回复评论: