【问题标题】:Can't clone any repository using git无法使用 git 克隆任何存储库
【发布时间】:2017-07-15 19:27:32
【问题描述】:

我尝试克隆几个存储库,但总是得到相同的错误。我在哪里可以找到有关此错误的更多信息(错误日志文件或类似内容),或者有人知道可能出了什么问题?

# git clone http://github.com/creationix/nvm.git .nvm
Initialized empty Git repository in /home/marcin/.nvm/.git/
error:  while accessing http://github.com/creationix/nvm.git/info/refs

fatal: HTTP request failed

# git clone https://gitlab.com/jmis/exilecraft.git
Initialized empty Git repository in /home/marcin/exilecraft/.git/
error:  while accessing https://gitlab.com/jmis/exilecraft.git/info/refs

fatal: HTTP request failed

我使用的是 CentOS 6.8 和 Git 1.7.1

--------- 编辑
将 Git 升级到 2.12.0 后出现错误消息:

# git clone https://github.com/creationix/nvm.git .nvm
Cloning into '.nvm'...
fatal: unable to access 'https://github.com/creationix/nvm.git/': Problem with the SSL CA cert (path? access rights?)  

【问题讨论】:

  • 作为数据点,在CentOS 6.8下使用git 1.7.1,我可以毫无问题地克隆第二个URL,如果我将http://更改为https://,我可以克隆第一个URL。如果我使用更新版本的git,问题就会完全消失。
  • 我尝试将 git 更新到最新版本,但 git clone 对我不起作用:/

标签: git centos


【解决方案1】:

如果您收到“SSL 连接错误”,请尝试更新 nss 和 curl。

例如在 CentOS 上:

yum update -y nss 卷曲

【讨论】:

    【解决方案2】:

    HTTPS cloning errors 中清楚地描述了该错误

    根据确切的错误消息,尝试在 url 中使用您的用户名进行克隆会有所帮助:

    git clone https://<username>@github.com/<username>/<repo.git>
    

    但理想情况下,您应该recompile and install a more recent version of Git

    使用 Git 版本 2.12.0,错误消息是:

    fatal: unable to access 'https://github.com/creationix/nvm.git/': 
    Problem with the SSL CA cert 
    

    确保您已安装证书:

    sudo yum reinstall openssl ca-certificates -y
    

    此修复的手动版本是:

    mkdir -p /etc/pki/tls/certs
    curl https://curl.haxx.se/ca/cacert.pem -o /etc/pki/tls/ca-bundle.crt
    git config --global http.sslcainfo /etc/pki/tls/ca-bundle.crt
    git config -l 
    

    另一个approach is described here

    mkdir /usr/src/ca-certificates && cd /usr/src/ca-certificates
    wget http://mirror.centos.org/centos/6/os/x86_64/Packages/ca-certificates-2015.2.6-65.0.1.el6_7.noarch.rpm
    rpm2cpio ca-certificates-2015.2.6-65.0.1.el6_7.noarch.rpm | cpio -idmv
    cp -pi ./etc/pki/tls/certs/ca-bundle.* /etc/pki/tls/certs/
    

    注意:edtech 添加in the comments

    升级 nss 包 (yum update nss) 为我解决了同样的问题。

    【讨论】:

    • 使用我的github用户名我得到fatal: HTTP request failed,现在我尝试重新编译Git
    • @MastaBot 您在顶级评论中提到已将 git 更新到最新版本。您收到什么错误消息?
    • 现在我有 Git 版本 2.12.0 仍然有错误,现在错误消息是 fatal: unable to access 'https://github.com/creationix/nvm.git/': Problem with the SSL CA cert (path? access rights?)
    • @MastaBot 也许您没有这些证书,请参阅我编辑的答案
    • yum reinstall ca-certificates 对我使用 SSL 的 apache 安全吗?
    【解决方案3】:

    可能有多种原因(代理、防火墙、公司政策等)。
    据我所知,github 已经取消了对 http 的支持,现在只支持 https

    把协议改成 ssh 就可以正常工作了。

    有一个非常详细的文档说明如何操作。
    https://help.github.com/articles/connecting-to-github-with-ssh/

    总结一下:

    • 在本地生成 ssh 密钥
      打开 git-bash/terminal 并生成密钥ssh-keygen
    • 复制密钥cat ~/.ssh/id_rsa.pub
    • 打开 git hub 并将密钥粘贴到您的配置文件设置下
    • 使用 ssh url 而不是 http/https 进行克隆。

    登录你的github账号

    • 在任意页面的右上角,点击您的个人资料照片,然后点击设置

    • 在用户设置侧边栏中,单击SSH 和 GPG 密钥

    .

    • 点击新建 SSH 密钥添加 SSH 密钥

    • 将您的密钥粘贴到 Key 字段中。

    • 点击添加 SSH 密钥

    • 如果出现提示,请确认您的 GitHub 密码。

    【讨论】:

    • 在 github 上添加 SSH Key 后我仍然得到同样的错误
    • 您是该项目的贡献者吗?如果它是一个私人仓库,你必须是贡献者才能克隆它。
    • 我只想更新我的 nvm(节点版本管理器)和所有(或许多指令如何从 git clone http://github.com/creationix/nvm.git 开始)
    • 也可以这样安装:curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.33.1/install.sh | bash
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-01-06
    • 2021-09-01
    • 2018-11-23
    • 2011-10-24
    • 2023-04-01
    相关资源
    最近更新 更多