Unable to clone github repository on Linux via HTTPS

I'm trying to make a simple git clone https://github.com/org/project.git in a CentOS field, but I get:

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

fatal: HTTP request failed

It never asks for my username / password, it just fails.

I can make the same call on my Mac without a problem - what am I missing?

+73
git linux github
Sep 21
source share
8 answers

The answer was simple, but not obvious:

Instead

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

to do:

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

or (unsafe)

 git clone https://username:password@github.com/org/project.git 

(Note that in the following case, your password will be displayed by other users on your computer by running ps u -u $you and by default it will be displayed in the shell history)

All 3 ways to work on my Mac, but only the last 2 worked in the remote Linux box. (Thinking about it, probably because I had a global git username set up on my Mac, while on the remote box I didnโ€™t โ€œMaybe it was, but the lack of a username hint helped me ...)

I havenโ€™t seen it registered anywhere, so here it is.

+183
Sep 21
source

You can manually disable ssl verfiy and try again. :)

 git config --global http.sslverify false 
+30
Sep 17 '13 at 5:52 on
source

Make sure you have git 1.7.10 or later, now it asks for the user / password correctly. (You can download the latest version here )

+12
Dec 17 '13 at 22:42
source

I needed to specify a username for working with version 1.7.1 git:

 git remote set-url origin https://username@github.com/org/project.git 
+9
Aug 13 '15 at 7:27
source

As JERC said, make sure you have an updated version of git. If you use only the default settings, when you try to install git, you will get version 1.7.1. Besides manually downloading and installing the latest version of get, you can also accomplish this by adding a new repository to yum.

From tecadmin.net :

Download and install the rpmforge repository:

 # use this for 64-bit rpm -i 'http://pkgs.repoforge.org/rpmforge-release/rpmforge-release-0.5.3-1.el6.rf.x86_64.rpm' # use this for 32-bit rpm -i 'http://pkgs.repoforge.org/rpmforge-release/rpmforge-release-0.5.3-1.el6.rf.i686.rpm' # then run this in either case rpm --import http://apt.sw.be/RPM-GPG-KEY.dag.txt 

Then you need to enable additional rpmforge features. Change /etc/yum.repos.d/rpmforge.repo and change enabled = 0 to enabled = 1 in the [rpmforge-extras] section. The file is as follows:

 ### Name: RPMforge RPM Repository for RHEL 6 - dag ### URL: http://rpmforge.net/ [rpmforge] name = RHEL $releasever - RPMforge.net - dag baseurl = http://apt.sw.be/redhat/el6/en/$basearch/rpmforge mirrorlist = http://mirrorlist.repoforge.org/el6/mirrors-rpmforge #mirrorlist = file:///etc/yum.repos.d/mirrors-rpmforge enabled = 1 protect = 0 gpgkey = file:///etc/pki/rpm-gpg/RPM-GPG-KEY-rpmforge-dag gpgcheck = 1 [rpmforge-extras] name = RHEL $releasever - RPMforge.net - extras baseurl = http://apt.sw.be/redhat/el6/en/$basearch/extras mirrorlist = http://mirrorlist.repoforge.org/el6/mirrors-rpmforge-extras #mirrorlist = file:///etc/yum.repos.d/mirrors-rpmforge-extras enabled = 0 ####### CHANGE THIS LINE TO "enabled = 1" ############# protect = 0 gpgkey = file:///etc/pki/rpm-gpg/RPM-GPG-KEY-rpmforge-dag gpgcheck = 1 [rpmforge-testing] name = RHEL $releasever - RPMforge.net - testing baseurl = http://apt.sw.be/redhat/el6/en/$basearch/testing mirrorlist = http://mirrorlist.repoforge.org/el6/mirrors-rpmforge-testing #mirrorlist = file:///etc/yum.repos.d/mirrors-rpmforge-testing enabled = 0 protect = 0 gpgkey = file:///etc/pki/rpm-gpg/RPM-GPG-KEY-rpmforge-dag gpgcheck = 1 

Once you do this, you can update git with

 yum update git 

I'm not sure why, but then they suggest disabling rpmforge-extras (change back to enabled = 0 ) and then run yum clean all .

Most likely you will need to use sudo for these commands.

+5
May 22 '14 at 16:48
source

I was able to get git 1.7.1 to work after a while.

Firstly, I had to disable SSL so that I could pull:

 git config --global http.sslverify false 

Then I could clone

 git clone https://github.com/USERNAME/PROJECTNAME.git 

Then after adding and committing, I was UNABLE to return. So what i did

 git remote -v origin https://github.com/USERNAME/PROJECTNAME.git (fetch) origin https://github.com/USERNAME/PROJECTNAME.git (push) 

to see push and push addresses:

They must be modified using USERNAME @

 git remote set-url origin https://USERNAME@github.com/USERNAME/PROJECTNAME.git 

It will still ask for a password, which you can add with

 USERNAME:PASSWORD@github..... 

But do not do this, as you keep your password clear for easy theft.

I had to make this combination because I could not get SSH to work due to firewall restrictions.

+4
Sep 22 '14 at 12:29
source

This is the dumbest answer to this question, but check the status of GitHub . It bothered me :)

+3
Aug 15 '13 at 16:25
source

I had the same problems and errors. In my case, it was not https_proxy. Setting the https_proxy environment variable fixed the problem.

 $ export https_proxy=https://<porxy_addres>:<proxy_port> 

Example:

 $ export https_proxy=https://my.proxy.company.com:8000 

Hope this helps someone.

+3
Jul 02 '15 at
source



All Articles