【问题标题】:Github: error cloning my private repositoryGithub:克隆我的私人存储库时出错
【发布时间】:2011-04-16 05:40:22
【问题描述】:

我正在尝试使用 https-URL 克隆我的 GitHub 项目,但它失败并出现错误:

$ git clone https://foo@github.com/foo/foo-private.git
Cloning into foo-private...
Password:
error: error setting certificate verify locations:
  CAfile: /bin/curl-ca-bundle.crt
  CApath: none
 while accessing https://foo@github.com/foo/foo-private.git/info/refs

fatal: HTTP request failed

我做错了什么?

【问题讨论】:

    标签: git github


    【解决方案1】:

    我在 Windows 上使用 msysgit 1.7.2.3 看到过这个。您必须修复 bin/curl-ca-bundle.crt 的路径。我必须使用反斜杠指定绝对路径:

    git config --system http.sslcainfo "C:\Program Files (x86)\git\bin\curl-ca-bundle.crt"

    这将导致 [git-install-dir]/etc/gitconfig 文件的更改,也可以直接编辑。

    (在http://github.com/blog/642-smart-http-support找到的原始解决方案)

    【讨论】:

    • 在我的情况下,我需要为 windows 使用目录分隔符,我的意思是,我必须使用“\”(windows)而不是“/”(unix)来分隔路径中的目录。
    • 因为下面的原始帖子对我有用 在公共存储库上尝试一下:$ git clone github.com/schacon/grack.git 对于私有存储库,或对您的存储库具有推送访问权限,您可以通过这种方式克隆:$ git clone username@github.com/username/project.git 谢谢 :)
    • 对于未来的参考,路径似乎已更改为“C:\Program Files (x86)\Git\mingw32\ssl\certs\ca-bundle.crt”
    • 我的 64 位机器上的路径是“C:\Program Files\Git\mingw64\ssl\certs\ca-bundle.crt”
    • 在我的 64 位机器上,git config --global http.sslcainfo "C:\Program Files\Git\mingw64\ssl\certs\ca-bundle.crt" 工作,无法说明为什么全局而系统失败。
    【解决方案2】:

    我解决了安装 Git 的问题:https://git-for-windows.github.io/ 找到证书文件路径:

    D:\Program Files\Git\mingw64\ssl\certs\ca-bundle.crt

    配置 Git 路径:

    git config --system http.sslcainfo "D:\Program 文件\Git\mingw64\ssl\certs\ca-bundle.crt"

    再试一次

    【讨论】:

    • 我收到了error: could not lock config file C:\Program Files\Git\mingw64/etc/gitconfig: Permission denied。以管理员身份运行"C:\Program Files\Git\git-bash.exe" 并再次尝试,它成功了。谢谢!
    • 更好的解释
    • 我刚刚为 Windows 2.13.2 安装了 Git,并在尝试推送到远程时遇到了这个问题。我发现证书文件位于类似的位置:C:\Program Files\Git\mingw64\ssl\certs\ca-bundle.crt
    • 这对我有用,我只使用你分享的链接安装了 Git,并且为我解决了这个问题,谢谢
    • 我在安装期间已将 GIT 安装在指定目录中,因此我必须根据该安装指定正确的 MINGW64 路径
    【解决方案3】:

    如果你使用 MSYS2...

    只需使用以下命令安装证书包:

    32 位

    pacman -S mingw-w64-i686-ca-certificates ca-certificates
    

    64 位

    pacman -S mingw-w64-x86_64-ca-certificates ca-certificates
    

    【讨论】:

    • 加一。谢谢。不记得必须这样做 msys2 32 位,但情况可能会有所不同。
    • 谢谢,我确认这是使用 msys2 64 位要做的事情:-D
    • 可能会出现 /usr/ssl/certs/ca-bundle.crt 文件为空,重新安装 ca-certificates 即可
    • 不适用于 Windows:$ pacman -S mingw-w64-x86_64-ca-certificates ca-certificates bash: pacman: command not found
    • @Javix 这就是为什么它说“如果你使用 MSYS2”。默认情况下,pacman 命令在 Windows 上不可用,但如果您安装了 MSYS2,则可以使用。
    【解决方案4】:

    如果您使用的是 Cygwin,您可以安装 ca-certificates 包 apt-cyg:

    wget rawgit.com/transcode-open/apt-cyg/master/apt-cyg
    install apt-cyg /usr/local/bin
    apt-cyg install ca-certificates
    

    How do I install a cygwin package from the command line?

    【讨论】:

    • 该死的。我找了这么久。这也在mac上解决了。谢谢分享。
    • 在 Cygwin 上它对我有用 git config --system http.sslcainfo /usr/ssl/certs/ca-bundle.crt
    【解决方案5】:
    git config --global http.sslverify "false" 
    

    将解决问题。 之后会出现一个弹出窗口,输入您的用户名和密码

    【讨论】:

    • 您可能想提一下它的安全后果。这似乎是一个糟糕的主意,尤其是在全球范围内。
    • 为我从事 HPC 工作
    【解决方案6】:

    已解决: 我在安装 Git Windows 安装程序的更新时收到此错误。发生的事情是我没有以管理员权限安装它,所以 Git 安装在“C:\Users\my_name\AppData\Local\Programs”而不是“C:\program Files”中。以管理员身份重新安装 Git 允许将其放入 C:\program 文件中,一切又恢复正常!

    【讨论】:

    • 不管怎样,卸载并重新安装 GitHub Desktop 也为我解决了这个问题,尽管它仍在使用 AppData 文件夹。
    【解决方案7】:

    这对我有用(我正在使用 Manjaro linux)。我运行 cmd 来查看 ca 证书:

    $ curl-config --ca
    **/etc/ssl/certs/ca-certificates.crt**
    

    但实际上我在路径中找到了证书:

    **/etc/ca-certificates/extracted/ca-bundle.trust.crt**
    

    然后将配置添加到 ~/.gitconfig 中(如果不存在,则创建它):

    **vim ~/.gitconfig**
    [http]
        sslVerify = true
        sslCAinfo = /etc/ca-certificates/extracted/ca-bundle.trust.crt
    
    [user]
        email = <email of github account>
        name = <username of github account>
    

    有效!

    .rbenv]$ git pull
    
    remote: Counting objects: 70, done.
    remote: Compressing objects: 100% (47/47), done.
    remote: Total 70 (delta 39), reused 12 (delta 12), pack-reused 6
    Unpacking objects: 100% (70/70), done.
    From https://github.com/sstephenson/rbenv
       c43928a..efb187f  master     -> origin/master
     + 37ec781...7e57b52 user-gems  -> origin/user-gems  (forced update)
    Updating c43928a..efb187f
    Fast-forward
     libexec/rbenv-init         |  4 ++--
     libexec/rbenv-version-file |  1 +
     test/init.bats             |  2 +-
     test/test_helper.bash      | 25 +++++++++++++++----------
     4 files changed, 19 insertions(+), 13 deletions(-)
    

    【讨论】:

    • 在archlinux上为我工作!
    【解决方案8】:

    git config --system http.sslcainfo /bin/curl-ca-bundle.crt

    这行得通。您不必提供完整路径。

    【讨论】:

      【解决方案9】:

      我在 git pull 时遇到了这个问题。为我编辑了修复问题的全局 git 配置文件。

      转到您的主文件夹并打开 .gitconfig 文件。通常是 C:\Users\.gitconfig

      如果文件不存在,则创建它

      [http]
      sslcainfo = E:\systools\git-1.8.5.2\bin\curl-ca-bundle.crt

      你必须提供你自己的 git 安装路径。我在这里使用了便携式版本的 git。

      然后 git clone / pull 就可以了。

      【讨论】:

      • 你需要使用双转义字符:E:\\systools...
      • 但是,请确保不要将路径括在引号中。超级反直觉。 "C:\\folder\\file" 不好,C:\\folder\\file 好。我想要我的时间回来。
      【解决方案10】:

      如果您使用随 GitHub for Windows 应用程序一起安装的 Git 命令外壳,则更新后可能会出现此问题和其他各种问题。只需启动 Git Hub Windows 应用程序并再次将其关闭。然后外壳将再次正常工作。问题是在 Windows 应用程序运行之前更新不会完成。仅在其上使用 shell 不会触发更新完成。

      【讨论】:

        【解决方案11】:

        我在我的 Github for Windows 上看到了这个。

        我建议卸载 Github for Windows 并重新安装。

        在此之前,我尝试了几种方法都没有成功,但是这个解决方案对我有用!

        【讨论】:

          【解决方案12】:

          在我的 win10 案例中,我有 两个版本的.gitconfig

          • 第一个在C:\Program Files\Git\etc
          • 第二个在C:\Users\&lt;user&gt;

          命令

          git config --system http.sslcainfo "C:\Program Files\Git\mingw64\ssl\certs\ca-bundle.crt"
          

          确实对 C:\Program Files\Git\etc 进行了更改,但 git 不知何故使用了 C:\Users\&lt;user&gt; 中的配置

          所以我用记事本更改了第二个.gitconfig,git 终于进行了正确的配置并开始工作。

          【讨论】:

          • 谢谢。我有同样的问题,找到你说的。使用git config --global 设置证书未在C:\Users\&lt;user&gt; 中正确设置路径,因此我不得不手动更新它并修复了问题。
          【解决方案13】:

          在使用 msysgit 的 Windows 上出现此错误,原因是我添加了我们的公司代理证书。

          如果你编辑你的 curl-ca-bundle.crt 你必须确定你的 lineendings。在 curl-ca-bundle 的情况下,您必须使用 Linux 样式的 lineendings。

          > git ls-remote --tags --heads https://github.com/oblador/angular-scroll.git
          fatal: unable to access 'https://github.com/oblador/angular-scroll.git/': error setting certificate verify locations:
            CAfile: C:\Program Files (x86)\Git\bin\curl-ca-bundle.crt
            CApath: none
          

          您可以使用 notepad++ 将换行符转换为 Linux(换行符)。

          【讨论】:

            【解决方案14】:

            附带说明,如果尝试使用 git 的用户与安装它的用户不同,则此问题可能发生在 Windows 中。该错误可能表明 git 无法访问证书文件。以管理员身份安装 git 并使用@rogertoday 的回答解决了我的问题。

            【讨论】:

              【解决方案15】:

              我为adding/updating the CA certificates on RHEL/CentOS 6 找到了一个很好的解决方案,这是报告问题的根本原因。

              由于它们成为过时的发行版,该系统中的 cacert 权限直到执行命令 sudo yum update 才更新。

              直到 GIT_CURL_VERBOSE 模式显示 cacert 路径问题时才意识到该问题。

              【讨论】:

                【解决方案16】:

                我在更新到 Visual Studio 2019 16.10.2(从 16.10.0)后遇到此错误,而之前 Git 工作正常。

                我没有单独安装 Git。 (或者,换一种说法,我只使用 Git 作为 Visual Studio 的一部分。)

                我通过在"C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\Common7\IDE\CommonExtensions\Microsoft\TeamFoundation\Team Explorer\Git\mingw32\ssl\certs\ca-bundle.crt" 找到文件"ca-bundle.crt",然后将其复制到它指示在"C:\Program Files\Git\mingw64\ssl\certs\ca-bundle.crt" 找不到它的文件夹中解决了这个问题。

                请注意,我必须创建“\mingw64\ssl\certs”目录,因为它们以前不存在。

                将文件复制到那里后,Git 能够立即再次同步,而无需重新启动 Visual Studio。

                【讨论】:

                  【解决方案17】:

                  在 Linux 上,我遇到了这个错误并通过运行 sudo update-ca-certificates 来修复它。

                  【讨论】:

                  • 你应该解释这个命令的作用以及为什么它会有所帮助。在没有解释的情况下发布原始命令不是一个好主意,特别是如果您需要 root 访问权限。
                  【解决方案18】:

                  如果其他人在 Git for Windows 中遇到此问题,并且即使重新安装后系统上的任何位置都没有 curl-ca-bundle.crt,这就是我遵循的过程:

                  1. 在此处下载最新版本的 curl:curl download mirror
                  2. 在命令行中提取并导航到curl-**.**.*/lib
                  3. 运行./mk-ca-bundle.prl
                  4. 将ca-bundle.crt 复制到您的git 路径并更新其他答案中列出的配置

                  感谢 this gist 帮助我完成安装。

                  【讨论】:

                    【解决方案19】:

                    我通过重新安装 Windows Server 2016 并在“选择 HTTPS 传输后端”安装步骤中选择“本机 Windows 安全通道库”解决了这个问题。

                    【讨论】:

                      【解决方案20】:

                      对于 Windows 10 上的 MinGit 用户:

                      您必须对@mstrap's answer 进行微调。

                      git config --system http.sslcainfo "<PATH-TO-MINGIT>\mingw64\ssl\certs\ca-bundle.crt"
                      

                      【讨论】:

                        【解决方案21】:

                        对我来说,解决问题的方法是在我的 windows 10 机器上,我尝试卸载 git 和resistalling,默认使用 Windows Cmd 而不是 Git Bash

                        打开CMD并运行以下命令

                        //Once installed try to resintall the bin folder 
                        git config --system http.sslcainfo \bin/curl-ca-bundle.crt
                        
                        //disable ssl verification
                        git config --global http.sslverify "false"
                        
                        //Then try to clone repo again
                        git clone git@github.com:account/someproject.git
                        

                        【讨论】:

                          【解决方案22】:

                          我在跨硬盘移动 git 后收到此错误。删除并在新位置重新安装固定的东西

                          【讨论】:

                            【解决方案23】:

                            在 Windows 的 git 上,您还可以重新安装并选择 Windows 原生证书验证方法(默认为 OpenSSL)。这将跳过 OpenSSL 验证,而是使用 Windows 原生验证,不需要维护单独的工具 (OpenSSL) 和证书。

                            非常适合我:)

                            【讨论】:

                              【解决方案24】:

                              在 windows 64bits 中适合我的解决方案如下

                              git config --system http.sslverify false

                              【讨论】:

                                【解决方案25】:

                                以下命令

                                git clone git://github.com/username/projectname.git
                                

                                满足我的需求,但我认为您想要的不仅仅是只读访问权限,对吧?

                                【讨论】:

                                  【解决方案26】:

                                  我能够使用以下命令解决此问题。

                                  git config --system http.sslverify false

                                  【讨论】:

                                  • 如果该答案讨论了此设置的安全后果并提供了其他解决问题的方法,则效果会更好。虽然,当前接受的答案可以做到这一点以及更多......
                                  猜你喜欢
                                  • 2012-01-14
                                  • 2020-09-23
                                  • 1970-01-01
                                  • 2021-07-09
                                  • 2021-06-19
                                  • 2018-09-21
                                  • 2021-12-31
                                  • 1970-01-01
                                  • 2019-01-19
                                  相关资源
                                  最近更新 更多