在克隆代码是出现访问不到github的情况
比如:
git clone https://github.com/WongKinYiu/PyTorch_YOLOv4.git
Cloning into ‘PyTorch_YOLOv4’…
fatal: unable to access ‘https://github.com/WongKinYiu/PyTorch_YOLOv4.git/’: Could not resolve host: github.com
打开终端,输入:
ping github.com
PING github.com (13.229.188.59) 56(84) bytes of data.
64 bytes from ec2-13-229-188-59.ap-southeast-1.compute.amazonaws.com (13.229.188.59): icmp_seq=2 ttl=44 time=278 ms
64 bytes from ec2-13-229-188-59.ap-southeast-1.compute.amazonaws.com (13.229.188.59): icmp_seq=3 ttl=44 time=279 ms
64 bytes from ec2-13-229-188-59.ap-southeast-1.compute.amazonaws.com (13.229.188.59): icmp_seq=4 ttl=44 time=284 ms
括号中的地址13.229.188.59
就是github.com
的实际地址.
将地址设置到配置文件:
sudo gedit /etc/hosts
原本的内容:
127.0.0.1 localhost
127.0.1.1 ubun
# The following lines are desirable for IPv6 capable hosts
::1 ip6-localhost ip6-loopback
fe00::0 ip6-localnet
ff00::0 ip6-mcastprefix
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters
将13.229.188.59 github.com
写到里面:
127.0.0.1 localhost
127.0.1.1 ubun
13.229.188.59 github.com
# The following lines are desirable for IPv6 capable hosts
::1 ip6-localhost ip6-loopback
fe00::0 ip6-localnet
ff00::0 ip6-mcastprefix
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters
再次使用git clone
git clone https://github.com/WongKinYiu/PyTorch_YOLOv4.git
Cloning into ‘PyTorch_YOLOv4’…
remote: Enumerating objects: 507, done.
remote: Total 507 (delta 0), reused 0 (delta 0), pack-reused 507
Receiving objects: 100% (507/507), 1.19 MiB | 6.00 KiB/s, done.
Resolving deltas: 100% (269/269), done.
克隆代码成功