Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can't clone a github repo on Linux via HTTPS

Tags:

git

linux

github

I'm trying to do a simple git clone https://github.com/org/project.git on a CentOS box but get:

error: The requested URL returned error: 401 while accessing https://github.com/org/project.git/info/refs

fatal: HTTP request failed

It never prompts me for my username/password, just fails.

I can make the exact same call on my Mac no problem- what am I missing?

like image 654
Yarin Avatar asked Sep 21 '12 21:09

Yarin


People also ask

Why is Git clone not working?

If you have a problem cloning a repository, or using it once it has been created, check the following: Ensure that the user has gone through initial GitCentric login and has the correct username, email, and ssh. This should return a usage message that refers to the config-branch, config-repo, and ls-repo commands.


2 Answers

The answer was simple but not obvious:

Instead of:

git clone https://github.com/org/project.git 

do:

git clone https://[email protected]/org/project.git 

or (insecure)

git clone https://username:[email protected]/org/project.git 

(Note that in the later case, your password will may be visible by other users on your machine by running ps u -u $you and will appear cleartext in your shell's history by default)

All 3 ways work on my Mac, but only the last 2 worked on the remote Linux box. (Thinking back on this, it's probably because I had a global git username set up on my Mac, whereas on the remote box I did not? That might have been the case, but the lack of prompt for a username tripped me up... )

Haven't seen this documented anywhere, so here it is.

like image 179
Yarin Avatar answered Sep 28 '22 21:09

Yarin


You can manual disable ssl verfiy, and try again. :)

git config --global http.sslverify false 
like image 33
Chu-Siang Lai Avatar answered Sep 28 '22 19:09

Chu-Siang Lai