我所做的:我在Github上创建了一个远程存储库,我试图在我的本地机器上克隆远程存储库。克隆时,我提供克隆URL和目标文件夹。

但每次我尝试克隆,我得到这个错误:

错误:“致命:无法访问https://github.com/hyperion057/spring-repo.git/':无法解决主机:github.com”

我需要做什么才能连接到GitHub ?


当前回答

我想说的是,当我做布莱恩的解时

git config --global --unset http.proxy

确保退出并重新启动终端。我的问题直到我这么做了才解决。

其他回答

我以前用过

service apache2 stop

如果你在Windows主机上使用wsl guest vm中的git,并连接到主机上的vpn来访问github,那么你可以在Windows主机配置中添加github的ip地址来临时解决这个问题。因为wsl2路由连接到vpn隧道有问题。 例如,在C:\Windows\System32\drivers\etc\hosts中添加如下行

# used from wsl, need update periodically
20.205.243.166  github.com
20.205.243.168  api.github.com

在Mac中重新启动终端工作正常。

对于Ubuntu服务器,你可以在/etc/network/interfaces文件中写下路由器的essid和密码:

iface [en0 || your wireless driver no necessarily en0] inet static
    address 192.168.1.100 / (something for your static ip between 1-255)
    netmask 255.255.255.0
    gateway 192.168.1.1 / (this is the ip of your router)
    dns-nameservers 8.8.8.8 / (you can use whatever you want)
    wpa-ssid qwertyuio / (this is router id)
    wpa-psk qwertyuio / (this is router password for wireless connection)

当我在将存储库拉到服务器时遇到这个错误时,我编写了wpa-ssid和wpa-psk并重新启动。然后就成功了。

编辑:我又遇到了同样的问题,这一次是因为路由器信号电平不一致。我的联系不牢固,这就是问题所在。然而,上面的解决方案是静态ip的真正解决方案

我想说的是,当我做布莱恩的解时

git config --global --unset http.proxy

确保退出并重新启动终端。我的问题直到我这么做了才解决。