简体   繁体   English

无法在 git 存储库中拉/推

[英]Unable to pull/push in git repository

$ git pull origin master
fatal: unable to access 'https://xxxxxxxxxxxxxxx': 
      error setting certificate verify locations:
CAfile: C:/Users/abc/AppData/Local/Programs/Git/usr/bin/curl-ca-bundle.crt
CApath: none

I am getting this error when I pull or push my code.当我拉或推我的代码时出现此错误。

Please guide me to fix this.请指导我解决这个问题。

When using https you will need to supply password or using a certificate.使用https您需要提供密码或使用证书。 In your case looks like the certificate is not a valid one.在您的情况下,该证书似乎无效。

Try fixing it like this by telling git where to find the certificate:尝试通过告诉 git 在哪里找到证书来修复它:

// Add the certificate to your configuration file
git config --system http.sslcainfo "C:\Program Files (x86)\git\bin\curl-ca-bundle.crt"

Alternatively, you could disable SSL checks:或者,您可以禁用 SSL 检查:

// or switch off SSL checks completely by executing:
git config --system http.sslverify false

Set this in your config to disable it only for the given url and not for all requests在您的配置中设置此项以仅针对给定的 url 而不是针对所有请求禁用它

[http "https://weak.example.com"]
    sslVerify = false

http.sslVerify

Whether to verify the SSL certificate when fetching or pushing over HTTPS.在获取或推送 HTTPS 时是否验证 SSL 证书。


http.sslCAInfo

File containing the certificates to verify the peer with when fetching or pushing over HTTPS包含在通过 HTTPS 获取或推送时用于验证对等方的证书的文件

I once had the same problem.我曾经遇到过同样的问题。 My problem occured after re-installing git for windows.我的问题是在为 Windows 重新安装 git 后出现的。 I'm using git for windows 64-bit on windows 10.我在 Windows 10 上将 git 用于 Windows 64 位。

I found out that the installer did not install git anymore in C:/Users/[USER_NAME]/AppData/Local/Programs/Git .我发现安装程序不再在C:/Users/[USER_NAME]/AppData/Local/Programs/Git Instead it installed it under C:\\Program Files\\Git .相反,它安装在C:\\Program Files\\Git

Nevertheless the old config file C:\\ProgramData\\Git\\config was not edited by the installer.尽管如此,安装程序并未编辑旧的配置文件C:\\ProgramData\\Git\\config This file still contains the old path so I edited it manually.该文件仍包含旧路径,因此我手动对其进行了编辑。

Eg on my system I used例如在我使用的系统上

[http]
     sslCAInfo = C:/Programme/Git/mingw64/ssl/certs/ca-bundle.crt

maybe you will have to use Program Files instead也许您将不得不改用Program Files

     sslCAInfo = C:/Program Files/Git/mingw64/ssl/certs/ca-bundle.crt

EDIT编辑

Like DS said in his comment就像DS在他的评论中所说

C:\\ProgramData\\Git\\config needs to be edited as Administrator . C:\\ProgramData\\Git\\config 需要以管理员身份编辑。

Eg right click on notepad and select "Run as Administrator" then open the file.例如,右键单击记事本并选择“以管理员身份运行”,然后打开该文件。

I was also facing this problem in windows and running git using gitbash.我也在 Windows 中遇到了这个问题,并使用 gitbash 运行 git。 I just reinstalled gitbash, And gitbash automatically managed git certificate and its path needed.我刚刚重新安装了gitbash,并且gitbash自动管理了git证书及其所需的路径。

In version 2.x of git-bash The path to the .crt has changed to ../Git/mingw64/ssl/certs/ca-bundle.crt.在 git-bash 2.x 版本中,.crt 的路径已更改为 ../Git/mingw64/ssl/certs/ca-bundle.crt。 I had to update this manually in git-bash with我必须在 git-bash 中手动更新它

 git config --global http.sslcainfo "/path/to/Git/mingw64/ssl/certs/ca-bundle.crt"

Try this尝试这个

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

or或者

Switch off your SSL by running this command通过运行此命令关闭 SSL

git config --system http.sslverify false
 git config --global http.sslverify "false" 
  • 将在出现弹出窗口输入您的用户名和密码确保有效后解决问题。

If your git version is 2.8.1.windows.1,this may help you.如果您的 git 版本是 2.8.1.windows.1,这可能对您有所帮助。 First , you need to locate your git home directory,mine is D:\\SDK\\Git.Just in the same directory,you can find folder "usr",open it and goes to \\ssl\\certs,you can find the certificate:ca-bundle.crt.首先,你需要找到你的git主目录,我的是D:\\SDK\\Git。就在同一个目录下,你可以找到文件夹“usr”,打开它并进入\\ssl\\certs,你可以找到证书: ca-bundle.crt。

Then open console,execute:然后打开控制台,执行:
git config --system http.sslcainfo "D:\\SDK\\Git\\usr\\ssl\\certscabundle.crt"

This will do the work while moving from GIT 2.x clients to 2.5.x:这将在从 GIT 2.x 客户端迁移到 2.5.x 时完成工作:

Looks like after installing a new version of GIT client, it changes the path it looks for certificates from something like this:看起来在安装新版本的 GIT 客户端后,它会更改查找证书的路径,如下所示:

C:\Program Files\Git\mingw64

to something like this:像这样:

C:\Program Files\Git\mingw64\libexec

To fix this, just copy the 'ssl' folder to the new location and it'll work like a charm!要解决这个问题,只需将“ssl”文件夹复制到新位置,它就会像魅力一样工作!

转到您的 git 目录并将 mingw64/ssl 文件夹移动到 mingw64/libexec/ssl

I was having this problem after installing devel packages on cygwin.在 cygwin 上安装开发包后我遇到了这个问题。

I tried all of the fixes in this thread but nothing was working.我尝试了此线程中的所有修复程序,但没有任何效果。

Then, I ran into this thread on github然后,我在github上遇到了这个线程

I found where CAPATH was being specified in gitconfig, and I deleted that https specification, and it solved my issue.我找到了在 gitconfig 中指定 CAPATH 的位置,然后删除了那个 https 规范,它解决了我的问题。

This thread is a lot of blind-leading-the-blind answers.这个线程是很多盲人引导盲人的答案。 I'm just one more blind man here, but I just had the same issue and solved it by following this easy article .我只是这里的另一个盲人,但我遇到了同样的问题,并按照这篇简单的文章解决了这个问题。 As I understand the original question, git is trying to find an SSL cert file in order to use the HTTPS protocol, and failing to find the file.据我了解原始问题,git 正在尝试查找 SSL 证书文件以使用 HTTPS 协议,但未能找到该文件。 Most of the answers here seem to focus on "well, just disable SSL then," rather than replacing the file correctly.这里的大多数答案似乎都集中在“好吧,那就禁用 SSL”,而不是正确替换文件。

This incantation should generate the cert file and put it in the correct location for git on cygwin:此咒语应生成证书文件并将其放在 cygwin 上 git 的正确位置:

$ curl -sL http://ca.pdinc.us > /etc/pki/ca-trust/source/anchors/ca.pdinc.us.pem \
&& update-ca-trust

In case you monkeyed with your git config (like I did) and need to set it BACK, this should do it:如果您使用 git 配置(就像我所做的那样)并需要将其设置为 BACK,则应该这样做:

$ git config --global http.sslcainfo "/etc/pki/ca-trust/extracted/openssl/ca-bundle.trust.crt"

One other side note which could be impacting many of the people reading this thread: The expected location of the cert file depends on which git executable you're running.另一边注可能会影响许多阅读此线程的人:cert 文件的预期位置取决于您正在运行的 git 可执行文件。 Since we're talking about Cygwin, some (most?) of us probably have a Windows-native flavor of git installed too.既然我们在谈论 Cygwin,那么我们中的一些人(大多数?)可能也安装了 Windows 本地风格的 git。 If your Cygwin paths are set up to find the Windows git executable, your mileage may vary in terms of where to point the http.sslcainfo configuration.如果您的 Cygwin 路径设置为查找 Windows git 可执行文件,则您的里程可能会因指向http.sslcainfo配置的位置而http.sslcainfo To check which executable is getting picked up for you:要检查为您挑选了哪个可执行文件:

$ which git

I got the same problem after my latest update of cygwin after installing Windows 10. The command update-ca-trust failed during installation.我在安装 Windows 10 后最新更新 cygwin 后遇到了同样的问题。命令update-ca-trust在安装过程中失败。

The reason seem to be that the group owner for the certificate folder was corrupt.原因似乎是证书文件夹的组所有者已损坏。 The somewhat drastic solution was to delete /etc/group , it turned out that cygwin is able to ask windows directly about group rights.有点激烈的解决方案是删除/etc/group ,结果证明 cygwin 能够直接向 windows 询问组权限。

Solution found at http://zaunerc.blogspot.se/2016/01/cygwin-mapping-windows-sids-to-posix.htmlhttp://zaunerc.blogspot.se/2016/01/cygwin-mapping-windows-sids-to-posix.html找到的解决方案

I found the ssl certificate at :我在以下位置找到了 ssl 证书:

C:\Users\[USERNAME]\AppData\Local\GitHub\PortableGit_[portable code]\usr\ssl\certs

then you can follow solution by CodeWizard ie :那么您可以按照CodeWizard 的解决方案进行操作,即:

// Add the certificate to your configuration file
git config --system http.sslcainfo "[LOCATION_SPECIFIED_ABOVE]/cabundle.crt"

Current Git for Windows build (2.18.0.windows.1) has a bug -- if the http.sslcainfo is not set it expects to find the certificate store in C:/Program Files/Git/mingw64/libexec/ssl/certs/ca-bundle.crt .当前用于 Windows 构建的 Git (2.18.0.windows.1) 有一个错误——如果没有设置 http.sslcainfo,它希望在C:/Program Files/Git/mingw64/libexec/ssl/certs/ca-bundle.crt找到证书存储C:/Program Files/Git/mingw64/libexec/ssl/certs/ca-bundle.crt

Certificate store is actually installed to C:/Program Files/Git/mingw64/ssl/certs/ca-bundle.crt so to fix that you must specify the proper path.证书存储实际上安装到C:/Program Files/Git/mingw64/ssl/certs/ca-bundle.crt以便修复您必须指定正确的路径。

Furthermore, the SCHANNEL implementation is also broken in this build.此外,此版本中的 SCHANNEL 实现也被破坏。

Finally, Git credential manager is also broken because if you have CI/CO credentials stored from gitlab-runner installation it will fail to clone/push/pull with access denied error instead of prompting for different credentials.最后,Git 凭证管理器也已损坏,因为如果您从 gitlab-runner 安装中存储了 CI/CO 凭证,它将无法克隆/推/拉并出现访问被拒绝错误,而不是提示输入不同的凭证。

This issue might occur when git client is not able to find trusted CA for ssl.当 git 客户端无法为 ssl 找到受信任的 CA 时,可能会出现此问题。 If you are in windows, try reinstalling it from https://gitforwindows.org/ .如果您使用的是 Windows,请尝试从https://gitforwindows.org/重新安装它。

During the installation, select "Use the native Windows Secure Channel library" option.在安装过程中,选择“使用本机 Windows 安全通道库”选项。 That option will allow you to use your company's internal Root CA certificate instead of default ca-bundle.crt该选项将允许您使用公司的内部根 CA 证书而不是默认的 ca-bundle.crt

在此处输入图片说明

Using Intellij and git-sdk-64, and picked git-sdk-64\\mingw64\\bin\\git.exe at first to be getting this issue, then when switched to git-sdk-64\\cmd\\git.exe it figured the cert file location alone and no other configuration was needed.使用 Intellij 和 git-sdk-64,首先选择git-sdk-64\\mingw64\\bin\\git.exe来解决这个问题,然后当切换到git-sdk-64\\cmd\\git.exe它认为cert 文件位置,不需要其他配置。 (have not used git config --global http.sslcainfo ... ) (没有使用git config --global http.sslcainfo ...

I have found the following steps useful in fixing the issue at my end for Windows 10:我发现以下步骤对于解决 Windows 10 的问题非常有用:

Doing an uninstall of git.正在卸载 git。

However, git uninstaller doesn't do a clean job.然而, git 卸载程序并没有做一个干净的工作。 So you may need to go delete the Git directory at C:\\Users[My name]\\AppData\\Local\\Programs\\因此,您可能需要删除 C:\\Users[My name]\\AppData\\Local\\Programs\\ 中的 Git 目录

After this, a fresh install of git should install install it in the C:\\Program Files\\Git directory where the config file points to in order to read the ssl certificate.在此之后,全新安装的 git 应该安装在配置文件指向的 C:\\Program Files\\Git 目录中,以便读取 ssl 证书。

I had the same error and I fixed it reinstalling git in the default path:我遇到了同样的错误,我修复了它,在默认路径中重新安装了 git:

C:\\Program Files\\Git C:\\Program Files\\Git

That's all就这样

I've got the same error message but in my case it was because I've changed github settings to use ssh instead of https.我收到了相同的错误消息,但就我而言,这是因为我已将 github 设置更改为使用 ssh 而不是 https。

And the repository with the problem was cloned with https after removing the remote and re-adding it with ssh it's working as expected.在删除远程并使用 ssh 重新添加后,有问题的存储库被 https 克隆,它按预期工作。

$git remote remove origin
$git remote add origin git@github.com:UserName/repo.git

Then git remote show origin is correctly showing the remote.然后git remote show origin正确显示遥控器。

I got the same error in Windows 7. Found that the certificate path referred in the error was not existing.我在 Windows 7 中遇到了同样的错误。发现错误中引用的证书路径不存在。 Instead of ...\\mingw32\\usr\\ssl... the cert file was in ...\\mingw2\\ssl... So I created a usr folder manually and moved the entire ssl tree into usr.而不是 ...\\mingw32\\usr\\ssl ... 证书文件在 ...\\mingw2\\ssl ... 所以我手动创建了一个 usr 文件夹并将整个 ssl 树移动到 usr 中。 This fixed the issue.这解决了这个问题。

Thanks to https://github.com/npm/npm/issues/1484感谢https://github.com/npm/npm/issues/1484
git config --global http.sslverify "false" will solve the problem git config --global http.sslverify "false"解决问题

I ran into the same error message but while cloning a github repository, unfortunately setting the http.sslcainfo didnt quite help.我遇到了相同的错误消息,但在克隆 github 存储库时,不幸的是设置http.sslcainfo没有http.sslcainfo帮助。 As I happened to be behind a corporate proxy server, setting the http.proxy fixed it for me.由于我碰巧在公司代理服务器后面,因此设置http.proxy为我修复了它。

I had previously installed git, then uninstalled it.我之前安装了 git,然后卸载了它。

So for me was as simple as reinstalling the correct version of git (for me win x64) from所以对我来说就像重新安装正确版本的git (对我来说是win x64)一样简单

https://git-scm.com/download/win https://git-scm.com/download/win

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM