赞
踩
记一次和github
的斗智斗勇。
fatal: unable to access ‘https://github.com/username/resposity.git/’: Failed to connect to github.com port 443: Timed out
fatal: unable to access ‘https://github.com/username/resposity.git/’: Empty reply from server
登录github网站时好时坏(用代理才可以登录),有时候显示没有响应,但是电脑以外的ipad登录顺利。(后来变成电脑和手机都无法等上,另有解决方法在后面)
本地使用 git clone / git push 报前述错误,代理也不行。
去网上寻求解决方法
三种方法:
- 检查是否有代理,若有取消:
git config --global --unset http.proxy
具体可见:
git clone出现 fatal: unable to access 'https://github.com/…'的解决办法(亲测有效)
知乎:fatal: unable to access;Failed connect to github.com:8087;- 改换ssh登录
- 注释掉 hosts下与github.com有关内容
具体可见:
解决git push时出现Failed to connect to github.com port 443: Timed out’
- hosts文件的作用:解析IP地址和主机名
- 我为什么会在hosts文件中设置github相关内容:为了解决曾经raw.githubusercontent.com 无法连接,网站上图片显示不出来的问题
于是我灵光一现,进行了如下尝试:
好景不长,在上面push成功后,很快我又push失败了。
根据之前经验多次尝试后(比如直接用查询到的IP地址登录网站),我发现我登不上去还是github
自身的问题。
- 当我可以用IP地址直接登录网站时,将IP地址映射添加进
hosts
文件才是有效的。- 当github可以直接登录不需要映射,将
hosts
文件中有关内容注释掉才是合适的。- 当上述都登不上时,改
hosts
无效。
重新思考情况,我发现开代理的情况下能登上网页版,但不能使用命令行。
报错:
fatal: unable to access ‘https://github.com/***/***.git/’: Unknown SSL protocol error in connection to github.com:443
询问室友她能否登上,得到开代理可以用的回答,开始寻找怎么在开代理的情况下使用命令行。
终于找到:
GitHub 无法连接问题
即:给 git 命令开代理。
但是输入上述文章中命令后,报错:
PCMV-Detector> git config --global http.proxy http://127.0.0.1:1087
PCMV-Detector> git push
fatal: unable to access ‘https://github.com/***/***.git/’: Failed to connect to 127.0.0.1 port 1087: Connection refused
再次思考,发现端口和我开的代理端口不同,修改命令端口为代理端口1080
:
顺便记录下可以使用git config --global -e
命令修改文本。
成功。
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。