32

I am having problem accessing github repository through Git Bash.

2 days ago I was able to push/pull the repositories. Then

1) I created an account on gitlab.com

2) I generated ssh key on my local pc following GitLab and SSH keys using git bash on windows

3) After this I did not create/pull/push any repository on gitlab.

Today I make few changes in a code (that is deployed on github), when I try to push that code I get following error

fatal: unable to access 'https://github.com/junaidbinsarfraz/repo.git/': error setting certificate verify locations:
  CAfile: E:/Softwares/Git/mingw64/libexec/ssl/certs/ca-bundle.crt
  CApath: none

There is no ssl folder in libexec

libexec folder

Also no file/folder changed in Git folder since Jan 2017

enter image description here

It seems like git-bash issue, not sure. Can anyone help ?

Junaid
  • 2,572
  • 6
  • 41
  • 77

8 Answers8

36

In my case, on windows, It was not working after setting of name, e mail as well as certificates path for git config. following command run from command prompt fixed this issue.

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

path of your ca-bundle.crt may vary in your case.

Vishal
  • 516
  • 5
  • 9
  • 1
    Ideal if you change GIT directory in your PC. In my case I changed from C:/Program Files to C:/Program Files (x86) – Leffa Jul 25 '22 at 17:51
9

First, creating ssh keys won't help for an HTTPS url.
Keep those keys, but if you want to use them, you would need to put existing ssh keys to your github account then

 cd /path/to/your/repo
 git remote set-url origin git@github.com:junaidbinsarfraz/repo.git
 git push

Second, regarding the cert error, try to push from a simple CMD, using a simplified PATH as I do here, with said PATH referencing the very latest Git for Windows.
For that, uncompress PortableGit-2.16.1-64-bit.7z.exe anywhere you want.

Junaid
  • 2,572
  • 6
  • 41
  • 77
VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
  • 1
    Thanks for prompt answer, I tried your solution but it gave me `Permission denied (publickey) fatal: Could not read from remote repository` error. So I disabled the git ssl verification. – Junaid Feb 01 '18 at 05:54
  • 1
    @Junaid is this your own repo? Did you registered your public ssh keys to your GitHub account? – VonC Feb 01 '18 at 05:56
  • 1
    Yeah, this is my own repo. I have many other repos but I never generated any ssh key on my Github account. – Junaid Feb 01 '18 at 05:59
  • 2
    @Junaid Then add your public key to your GitHub account and my answer will work: https://help.github.com/articles/adding-a-new-ssh-key-to-your-github-account/. Just use a SSH key without passphrase, to avoid the hassle to the ssh-agent. – VonC Feb 01 '18 at 06:01
  • 1
    It worked. First, I added the generated key to the github then `git remote set-url origin git@github.com:junaidbinsarfraz/repo.git` and push. – Junaid Feb 01 '18 at 06:07
  • 1
    One question, for other repositories can't I use `git remote set-url origin https://github.com/junaidbinsarfraz/other-repo.git` ? – Junaid Feb 01 '18 at 06:08
  • 1
    @Junaid yes provided you enter your username/GitHub password at the first git push. If GitHub does not ask for your passwords, it means they are cached by the credential credential manager: https://stackoverflow.com/a/48466698/6309 – VonC Feb 01 '18 at 06:17
2

On openSUSE 15.2 WSL (Windows Subsystem for Linux), I fixed this error by:

sudo update-ca-certificates 
sudo mkdir -p /etc/pki/tls/certs/
sudo cp /etc/ssl/ca-bundle.pem /etc/pki/tls/certs/ca-bundle.crt  

/etc/pki/tls/certs/ca-bundle.crt was the certificate file mentioned in the error. I noticed the file was missing. The full error in my case was:

fatal: unable to access 'https://github.com/vim/vim.git/': error setting certificate verify locations:
  CAfile: /etc/pki/tls/certs/ca-bundle.crt
  CApath: none
Nathan Mills
  • 2,243
  • 2
  • 9
  • 15
1

For windows i found the same error having cloned successfully using GitHub desktop . When I tried doing a sync using Visual Studio, the error appeared.

My GitHub desktop runs 64 bit, but it has its git folder was placed in the Program (x86) folder (why?) The VS is also a 64 bit application, but has the certicate more naturally in the Program folder.

Solution: I copied content of C:\Program Files (x86)\Git\mingw32\ssl to C:\Program Files\Git\mingw64\ssl

And the Git of VS worked perfect

Mads Lundwall
  • 11
  • 1
  • 4
0

Fix

git config --global --replace-all http.sslcainfo "E:\Program Files\Git\usr\ssl\certs\ca-bundle.crt"
Adriaan
  • 17,741
  • 7
  • 42
  • 75
  • 4
    Your answer could be improved with additional supporting information. Please [edit] to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community May 19 '23 at 10:30
0

Check if git is installed. git --version

Install git.

Antonio
  • 1
  • 1
-1

One of my team member came to my seat with this error and I have identified that git was not installed on the system that's why he was getting this error.

Although Microsoft does suggest to install Git for Windows but you don't have to install it for the Visual Studio 2013 or 2017 as the same page ends with:

Visual Studio offers a great out of the box Git experience without any additional tooling. Learn more in our Visual Studio Git tutorial.

Git comes as an optional component for Visual Studio 2019 ,and you need to manually install it to work with Git servers such as Team Foundation Services, GitHub, and BitBucket. You can find more details about this here

Asad
  • 498
  • 7
  • 21
  • 2
    you cannot get this error if git is not installed on the system. it is an error from git. – eis Oct 12 '22 at 08:48
  • 1
    If git wasn't installed, you'd get "command not recognized" when you tried to `git push`. – pabrams Mar 01 '23 at 16:44
-2

Solution:

git config --global http.sslverify "false"

This command, Then your usual git clone "url" thing.

It can cause trouble in future to pull/push the secure repository. So disable at your risk.

Gaurav Kumar
  • 115
  • 2
  • 7