git 无法连接到 GitHub.com 进行克隆

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/16298986/
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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-10 16:03:39  来源:igfitidea点击:

Unable to Connect to GitHub.com For Cloning

gitgithubgit-bashgit-clone

提问by Mohamed Hussain

I am trying to clone the angular-phonecat git repository, but I am getting the following message when I enter the command in my Git Bash:

我正在尝试克隆angular-phonecat git 存储库,但是当我在 Git Bash 中输入命令时收到以下消息:

$ git clone git://github.com/angular/angular-phonecat.git  
Cloning into 'angular-phonecat'...  
fatal: unable to connect to github.com:  
github.com[0: 204.232.175.90]: errno=No error

回答by Chronial

You are probably behind a firewall. Try cloning via https – that has a higher chance of not being blocked:

您可能位于防火墙后面。尝试通过 https 进行克隆 - 这样更有可能不被阻止:

git clone https://github.com/angular/angular-phonecat.git

回答by bnguyen82

You can make git replace the protocol for you

你可以让 git 为你替换协议

git config --global url."https://".insteadOf git://

See more at SO Bower install using only https?

仅使用 https 的SO Bower 安装中查看更多信息

回答by rneha725

I had the same error because I was using proxy. As the answer is given but in case you are using proxy then please set your proxy first using these commands:

我有同样的错误,因为我使用的是代理。由于给出了答案,但如果您使用代理,请先使用以下命令设置您的代理:

git config --global http.proxy http://proxy_username:proxy_password@proxy_ip:port
git config --global https.proxy https://proxy_username:proxy_password@proxy_ip:port

回答by Chris Halcrow

Open port 9418 on your firewall - it's a custom port that Git uses to communicate on and it's often not open on a corporate or private firewall.

在防火墙上打开端口 9418 - 它是 Git 用来进行通信的自定义端口,通常不会在公司或私人防火墙上打开。

回答by Deepak Sasindran

You can try to clone using the HTTPSprotocol. Terminal command:

您可以尝试使用该HTTPS协议进行克隆。终端命令:

git clone https://github.com/RestKit/RestKit.git