最近在学习git的使用,在建立本地git库并申请了远程GitHub库,想要将本地库关联我的远程库。
就使用以下命令:
git remote add origin https://github.com/Username/git.git
注:将Username更换为你自己的GitHub账户名
然后使用以下命令将本地的分支推送到远程:
git push -u origin master
这时便出现了错误:
error: Failed connect to github.com:443; Connection refused while accessing https://github.com/JasonLiu1991/git.git/info/refs
fatal: HTTP request failed

就这个问题折腾了半天,终于解决了。
首先说明我的系统是Ubuntu,解决办法就是打开/etc/hosts文件,将github.com对应的行屏蔽掉就可以了。

如图显示,屏蔽前三行。
现在再去git push就会发现问题解决了,解决方法虽简单,但是找到解决方法的过程很艰辛。