在 git 中克隆远程存储库时无法解决主机 github.com 错误
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/20370294/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
could not resolve host github.com error while cloning remote repository in git
提问by HyperioN
What I did: I have created a remote repository on Github and I am trying to clone the remote repository on my local machine. While cloning I am providing the clone URL & target folder.
我做了什么:我在 Github 上创建了一个远程存储库,我正在尝试在我的本地机器上克隆远程存储库。克隆时,我提供了克隆 URL 和目标文件夹。
But every time I try to clone, I am getting this error:
但是每次我尝试克隆时,都会收到此错误:
Error: "fatal: unable to access 'https://github.com/hyperion057/spring-repo.git/': Could not resolve host: github.com"
错误:“致命:无法访问‘ https://github.com/hyperion057/spring-repo.git/’:无法解析主机:github.com”
What do I need to do to connect to GitHub ?
我需要做什么才能连接到 GitHub?
采纳答案by VonC
do i need to configure proxy settings? because my office has got proxy servers.
我需要配置代理设置吗?因为我的办公室有代理服务器。
Yes, you can do so by setting HTTP_PROXY
, and HTTPS_PROXY
environment variables.
是的,您可以通过设置HTTP_PROXY
, 和HTTPS_PROXY
环境变量来实现。
See "Syncing with github":
参见“与 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
Note the NO_PROXY
, to allow to access internal site to your company
请注意NO_PROXY
, 以允许访问您公司的内部站点
You also can register that in your git config:
你也可以在你的 git 配置中注册:
git config --global http.proxy http://<login_internet>:<password_internet>@aproxy:aport
But if you have incorrect proxy Git settings, remove them:
但是,如果您的代理 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
回答by Brian
I got a similar error, and it's caused by incorrect proxy setting. This command saved me:
我遇到了类似的错误,它是由不正确的代理设置引起的。这个命令救了我:
git config --global --unset http.proxy
https version:
https版本:
git config --global --unset https.proxy
回答by Chris Fremgen
Spent a couple hours trying to fix this.
花了几个小时试图解决这个问题。
Re-connecting my wifi did the trick.
重新连接我的 wifi 成功了。
回答by Chadams
another possibility, I ran into this problem myself. But it was after I had installed a VPN (which was unrelated and running)
另一种可能性,我自己遇到了这个问题。但那是在我安装了 VPN(无关且正在运行)之后
turning off the VPN, fixed the issue.
关闭VPN,解决了问题。
for the record, I was running "Viscosity" VPN on my MacBookPro
作为记录,我在我的 MacBookPro 上运行了“Viscosity”VPN
回答by delrox
I've had the same issue after running out of disk space. Closing and reopening terminal fixed it one time. Restarting my Mac the next.
磁盘空间不足后,我遇到了同样的问题。关闭并重新打开终端修复了一次。接下来重新启动我的 Mac。
Some easy things to try before jumping to random commands:
在跳转到随机命令之前尝试一些简单的事情:
- restart terminal tab
- restart terminal app
- If disk is full (or close to it) free up some disk space then restart terminal app
- restart machine/OS
- 重新启动终端选项卡
- 重启终端应用
- 如果磁盘已满(或接近)释放一些磁盘空间,然后重新启动终端应用程序
- 重启机器/操作系统
回答by Developer
192.30.252.128 is the current IP of github.com which can be set in your local DNS (/etc/hosts in Linux and C:\Windows\System32\drivers\etc\hosts)
192.30.252.128是github.com的当前IP,可以在本地DNS设置(Linux下为/etc/hosts,C:\Windows\System32\drivers\etc\hosts)
回答by agrippa
Would like to note, when I did Brian's solution:
想注意,当我做布赖恩的解决方案时:
git config --global --unset http.proxy
make sure to quit and restart terminal. Mine didn't resolve until I did that.
确保退出并重新启动终端。我的没有解决,直到我这样做。
Thanks so much, issue was killing me!
非常感谢,问题正在杀死我!
回答by Ankit Bhardwaj
i have same issue and solve it by using this command
我有同样的问题并使用此命令解决它
$git config --global http.proxy http://enter_your_proxy:enter_port
$git config --global http.proxy http://enter_your_proxy:enter_port
回答by John Yin
I had this very similar error as following.
我有这个非常相似的错误如下。
C:\wamp\www\myrepository [master]> git push
fatal: unable to access 'https://github.com/myaccount/myrepository.git/': Couldn't resolve host 'github.com'
Actually, the prompt message has told us where's wrong.
其实,提示信息已经告诉我们哪里出了问题。
https://github.com/myaccount/myrepository.git/
When I check my github, I found my github repository's HTTPS url is
当我检查我的 github 时,我发现我的 github 存储库的 HTTPS url 是
https://github.com/myaccount/myrepository.git
I don't know how this happened. The wrong url has been set up by installed Git Shell automatically.
我不知道这是怎么发生的。错误的 url 已被安装的 Git Shell 自动设置。
Once I remove the '/' at the end, I can push successfully.
一旦我删除了最后的“/”,我就可以成功推送。
回答by johnwbyrd
In my case, on a Windows box, my TCP/IP stack seems to have needed to be reset. Resetting the TCP/IP stack of the client PC caused git to start behaving properly again. Run this command in Administrator mode at a command prompt and retry the git command:
就我而言,在 Windows 机器上,我的 TCP/IP 堆栈似乎需要重置。重置客户端 PC 的 TCP/IP 堆栈会导致 git 再次开始正常运行。在命令提示符下以管理员模式运行此命令,然后重试 git 命令:
netsh int ip reset
Manually disabling and re-enabling the network adapter via the Control Panel produces a similar result.
通过控制面板手动禁用和重新启用网络适配器会产生类似的结果。
I suspect DNS resolution problems inside the TCP stack on my Windows box.
我怀疑 Windows 机器上 TCP 堆栈内的 DNS 解析问题。