我所做的:我在Github上创建了一个远程存储库,我试图在我的本地机器上克隆远程存储库。克隆时,我提供克隆URL和目标文件夹。
但每次我尝试克隆,我得到这个错误:
错误:“致命:无法访问https://github.com/hyperion057/spring-repo.git/':无法解决主机:github.com”
我需要做什么才能连接到GitHub ?
我所做的:我在Github上创建了一个远程存储库,我试图在我的本地机器上克隆远程存储库。克隆时,我提供克隆URL和目标文件夹。
但每次我尝试克隆,我得到这个错误:
错误:“致命:无法访问https://github.com/hyperion057/spring-repo.git/':无法解决主机:github.com”
我需要做什么才能连接到GitHub ?
当前回答
我也犯过类似的错误。
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回购),主机被挂起,所以问题是我的GitHub服务器和管理员解决了它。
我需要配置代理设置吗?因为我办公室有代理服务器。
是的,您可以通过设置HTTP_PROXY和HTTPS_PROXY环境变量来做到这一点。
参见“同步与github”:
set HTTPS_PROXY=http://<login_internet>:<password_internet>@aproxy:aport
set HTTP_PROXY=http://<login_internet>:<password_internet>@aproxy:aport
set NO_PROXY=localhost,my.company
(为了避免在代理URL中明确放置您的凭据—用户名/密码,请参见下文)
注意NO_PROXY,允许访问您公司的内部站点
你也可以在你的git配置中注册:
git config --global http.proxy http://<login_internet>:<password_internet>@aproxy:aport
但是如果你有不正确的代理Git设置,请删除它们:
cd /path/to/repo
git config --unset http.proxy
git config --global --unset http.proxy
git config --system --unset http.proxy
git config --unset https.proxy
git config --global --unset https.proxy
git config --system --unset https.proxy
# double-check with:
git config -l --show-origin | grep -i proxy
不需要凭证:使用genotrance/px。 如果你像我一样,在一个NTLM代理背后的公司,你所需要做的就是:
解压缩px-v0.4.0.zip到任何你想要的地方 更改px.ini配置文件(把它放在%USERPROFILE%),更改服务器行: (代理) Server = proxy.my.company:8080 <=使用您公司的proxy:port Listen = 127.0.0.1 端口= 3128 使用HTTP(S)代理变量没有您的凭据!(px代理将通过Microsoft SSPI或Microsoft Kerberos重用当前寡妇会话中的文件)
这将给你:
set HTTPS_PROXY=http://127.0.0.1:3128
set HTTP_PROXY=http://127.0.0.1:3128
set NO_PROXY=localhost,my.company
对于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的真正解决方案
在通过https克隆git存储库时,我遇到了这个问题的另一个版本:
致命:无法访问'https://GIT_USER:GIT_PASSWORD@github.com/organization/repo.git/':无法解析主机:GIT_USER
问题是密码中有限制字符,需要进行URL编码。此外,如果您使用2FA(双因素身份验证),则应使用个人访问令牌来代替密码。
搜索上面的错误条件会在谷歌上找到这个页面,所以希望这个答案能节省一些人的时间。
在Mac中重新启动终端工作正常。