MastaBot
MastaBot

Reputation: 277

Can't clone any repository using git

I tried cloning a few repositories, but always get the same error. Where can I find some more information about this error (an error log file or something similar) or maybe someone knows what can be wrong?

# 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

or

# 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

I'm using CentOS 6.8 and Git 1.7.1

---------- EDIT
after upgrade Git to 2.12.0 I have error message:

# 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?)  

Upvotes: 3

Views: 10728

Answers (3)

Valéry
Valéry

Reputation: 354

If you are getting "SSL connect error" try to update nss and curl.

For example on CentOS:

yum update -y nss curl

Upvotes: 1

VonC
VonC

Reputation: 1328652

That error is clearly described in HTTPS cloning errors

Depending on the exact error message, trying to clone with your username in the url can help:

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

But ideally, you should recompile and install a more recent version of Git.

With Git version 2.12.0, the error message is:

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

Make sure you have installed the certificates:

sudo yum reinstall openssl ca-certificates -y

The manual version of this fix is:

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 

Another 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/

Note: edtech adds in the comments:

Upgrading the nss package ( yum update nss ) has solved the same problem for me.

Upvotes: 5

CodeWizard
CodeWizard

Reputation: 142552

There can be a variety of reasons (proxy, firewall, company policy and more).
As far as i know github has removed the support for the http and now only support https

Change the protocol to ssh and it will work without any problems.

There is a very detailed document on how to do it.
https://help.github.com/articles/connecting-to-github-with-ssh/

To summarize it:

  • Generate ssh key locally
    open git-bash/terminal and generate the key ssh-keygen
  • Copy the key cat ~/.ssh/id_rsa.pub
  • open git hub ans paste the key under your profile settings
  • Clone with the ssh url instead of the http/https.

Login to your github account

  • In the upper-right corner of any page, click your profile photo, then click Settings.

enter image description here

  • In the user settings sidebar, click SSH and GPG keys

enter image description here.

  • Click New SSH key or Add SSH key.

enter image description here

  • Paste your key into the Key field.

enter image description here

  • Click Add SSH key.

enter image description here

  • If prompted, confirm your GitHub password.

enter image description here

Upvotes: 2

Related Questions