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

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

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

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


当前回答

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

git config --global --unset http.proxy

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

其他回答

我用这个命令解决了它

$git config --global http.proxy http://enter_your_proxy:enter_port

对于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的真正解决方案

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

我也犯过类似的错误。

C:\wamp\www\myrepository [master]> git push
fatal: unable to access 'https://github.com/myaccount/myrepository.git/': Couldn't resolve host 'github.com'

实际上,提示信息已经告诉我们哪里出错了。

https://github.com/myaccount/myrepository.git/

当我检查我的github,我发现我的github仓库的HTTPS url是

https://github.com/myaccount/myrepository.git

我不知道这是怎么回事。安装的Git Shell自动设置了错误的url。

一旦我删除了末尾的“/”,我就可以成功地推了。

重启后,git bash下面的工作对我来说很好:

git push -f origin master