无法在 git 存储库中拉/推

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/34510018/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-09 03:47:42  来源:igfitidea点击:

Unable to pull/push in git repository

gitgithub-for-windows

提问by Arvind

$ 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.

请指导我解决这个问题。

采纳答案by René Link

I was also facing this problem in windows and running git using gitbash. I just reinstalled gitbash, And gitbash automatically managed git certificate and its path needed.

我也在 Windows 中遇到了这个问题,并使用 gitbash 运行 git。我刚刚重新安装了gitbash,并且gitbash自动管理了git证书及其所需的路径。

回答by CodeWizard

When using httpsyou will need to supply password or using a certificate. In your case looks like the certificate is not a valid one.

使用时,https您需要提供密码或使用证书。在您的情况下,该证书似乎无效。

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

http.sslVerify

Whether to verify the SSL certificate when fetching or pushing over HTTPS.

在获取或推送 HTTPS 时是否验证 SSL 证书。



http.sslCAInfo

http.sslCAInfo

File containing the certificates to verify the peer with when fetching or pushing over HTTPS

包含在通过 HTTPS 获取或推送时用于验证对等方的证书的文件

回答by René Link

I once had the same problem. My problem occured after re-installing git for windows. I'm using git for windows 64-bit on windows 10.

我曾经遇到过同样的问题。我的问题是在为 Windows 重新安装 git 后出现的。我在 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. Instead it installed it under C:\Program Files\Git.

我发现安装程序不再在 .git 中安装 git C:/Users/[USER_NAME]/AppData/Local/Programs/Git。相反,它安装在 C:\Program Files\Git.

Nevertheless the old config file C:\ProgramData\Git\configwas not edited by the installer. This file still contains the old path so I edited it manually.

尽管如此C:\ProgramData\Git\config,安装程序并未编辑旧的配置文件。该文件仍包含旧路径,因此我手动对其进行了编辑。

E.g. on my system I used

例如在我使用的系统上

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

maybe you will have to use Program Filesinstead

也许你将不得不Program Files改用

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

EDIT

编辑

Like DSsaid in his comment

就像DS在他的评论中所说

C:\ProgramData\Git\config needs to be edited as Administrator.

C:\ProgramData\Git\config 需要以管理员身份编辑。

E.g. right click on notepad and select "Run as Administrator"then open the file.

例如,右键单击记事本并选择“以管理员身份运行”,然后打开该文件。

回答by stiteler

In version 2.x of git-bash The path to the .crt has changed to ../Git/mingw64/ssl/certs/ca-bundle.crt. I had to update this manually in git-bash with

在 git-bash 的 2.x 版本中,.crt 的路径已更改为 ../Git/mingw64/ssl/certs/ca-bundle.crt。我必须在 git-bash 中手动更新它

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

回答by Prabu Guna

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

回答by Abu Bakr

 git config --global http.sslverify "false" 
  • will solve the problem after that Pop-up window appear to enter your username and password make sure valid .
  • 将在出现弹出窗口输入您的用户名和密码确保有效后解决问题。

回答by Naor Bar

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”文件夹复制到新位置,它就会像魅力一样工作!

回答by dav dai

If your git version is 2.8.1.windows.1,this may help you. 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 版本是 2.8.1.windows.1,这可能对您有所帮助。首先,你需要找到你的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"

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

回答by Soyuzbek Orozbek Uulu

Go your git directory and move the mingw64/ssl folder to mingw64/libexec/ssl

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

回答by Steven

For future readers:

对于未来的读者:

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上遇到了这个线程

What I did was I found where CAPATH was being specified in gitconfig, and I deleted that https specification, and it solved my issue.

我所做的是找到了在 gitconfig 中指定 CAPATH 的位置,然后删除了那个 https 规范,它解决了我的问题。