当前位置:   article > 正文

Ubuntu中“fatal: unable to access ‘https://github.com/xxxx/xxxx.git‘: Failed to connect to 127……”解决方案_ubuntu git clone失败fatal: unable to access

ubuntu git clone失败fatal: unable to access

我们在使用git clone项目时候经常会遇到“

fatal: unable to access 'https://github.com/xxxx/xxxx.git': Failed to connect to 127.0.0.1 port 8087: Connection refused

   
   
  • 1
  • 2

”此类错误。面对此类错误我总结了三种解决方法,选择适合自己的才是最好的,能解决问题的方案才是好方案。

 

第一种方法:

将“git clone https://github.com/Z3Prover/z3.git”中的“https”更换为“git”。即为“git clone git://github.com/Z3Prover/z3.git”。这种方法最为简单有效,如过还是报错可尝试第二种方法。亲测有效

 

第二种方法: 

可以尝试这位博主的两种方案,这两种方法都没有解决我的问题,你们可以试一下,有人说可以解决。转自:https://blog.csdn.net/dashi_lu/article/details/89641778

 

第三种方法:git环境通过ssh链接GitHub(免密码)配置,亲测有效

 

1.  安装git 

sudo apt-get install git
    
    
  • 1

2.  配置用户信息


    
    
  1. $ git config -- global user. name "Your Name"
  2. $ git config -- global user. email Your_email @example. com
  • 1

3.  初始化本地仓库设置

git init
    
    
  • 1

 通过ssh连接GitHub

1.  安装ssh

sudo apt-get install ssh
    
    
  • 1

ssh-keygen 会确认密钥的存储位置和文件名(默认是 .ssh/id_rsa),然后他会要求你输入两次密钥口令,留空即可。所以一般选用默认,全部回车即可。 如下图所示

2.  创建秘钥文件

ssh-keygen -t rsa -C "你的github账号邮箱"
    
    
  • 1

 3.  将公钥添加到GitHub账户

      (1)将id_rsa.pub文件内容全部复制;

      (2)登陆到GitHub上,右上角小头像->Setting->SSH and GPG keys中,点击new SSH key。

4.  ssh测试

ssh -T git@github.com
    
    
  • 1

结果为:,表示配置成功。

4.  使用 git clone https://github.com/Z3Prover/z3.git,测试是否真的成功?

在我的机器上又报了如下错误:

5.  原因是你的git buffer太低了。为解决上述报错,需要执行:

git config --global http.postBuffer 50M
    
    
  • 1

再次执行 git clone https://github.com/Z3Prover/z3.git。结果如下:

已经可以成功clone项目了。

 

总结:问题很小,但是解决问题的方案很多,我只是将这几种方法总结到了一起,如果其他问题,欢迎一起讨论,也欢迎批评指正。谢谢大家

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/代码探险家/article/detail/1012638
推荐阅读
相关标签
  

闽ICP备14008679号