Can't clone a github repo on Linux via HTTPS

前端 未结 9 1408
别跟我提以往
别跟我提以往 2020-12-02 06:47

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:

相关标签:
9条回答
  • 2020-12-02 07:07

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

    0 讨论(0)
  • 2020-12-02 07:16

    As JERC said, make sure you have an updated version of git. If you are only using the default settings, when you try to install git you will get version 1.7.1. Other than 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 the rpmforge-extras. Edit /etc/yum.repos.d/rpmforge.repo and change enabled = 0 to enabled = 1 under [rpmforge-extras]. The file looks like this:

    ### 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've done this, then you can update git with

    yum update git
    

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

    Most likely you'll need to use sudo for these commands.

    0 讨论(0)
  • 2020-12-02 07:23

    I had to specify user name to work on 1.7.1 git version:

    git remote set-url origin https://username@github.com/org/project.git
    
    0 讨论(0)
  • 2020-12-02 07:25

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

    git config --global http.sslverify false
    
    0 讨论(0)
  • 2020-12-02 07:26

    I met the same problem, the error message and OS info are as follows

    OS info:

    CentOS release 6.5 (Final)

    Linux 192-168-30-213 2.6.32-431.el6.x86_64 #1 SMP Fri Nov 22 03:15:09 UTC 2013 x86_64 x86_64 x86_64 GNU/Linux

    error info:

    Initialized empty Git repository in /home/techops/pyenv/.git/ Password: error: while accessing https://waterdrops@github.com/pyenv/pyenv.git/info/refs

    fatal: HTTP request failed

    git & curl version info

    git info :git version 1.7.1

    curl 7.19.7 (x86_64-redhat-linux-gnu) libcurl/7.19.7 NSS/3.14.0.0 zlib/1.2.3 libidn/1.18 libssh2/1.4.2 Protocols: tftp ftp telnet dict ldap ldaps http file https ftps scp sftp Features: GSS-Negotiate IDN IPv6 Largefile NTLM SSL libz

    debugging

    $ curl --verbose https://github.com

    • About to connect() to github.com port 443 (#0)
    • Trying 13.229.188.59... connected
    • Connected to github.com (13.229.188.59) port 443 (#0)
    • Initializing NSS with certpath: sql:/etc/pki/nssdb
    • CAfile: /etc/pki/tls/certs/ca-bundle.crt CApath: none
    • NSS error -12190
    • Error in TLS handshake, trying SSLv3... GET / HTTP/1.1 User-Agent: curl/7.19.7 (x86_64-redhat-linux-gnu) libcurl/7.19.7 NSS/3.14.0.0 zlib/1.2.3 libidn/1.18 libssh2/1.4.2 Host: github.com Accept: /

    • Connection died, retrying a fresh connect

    • Closing connection #0
    • Issue another request to this URL: 'https://github.com'
    • About to connect() to github.com port 443 (#0)
    • Trying 13.229.188.59... connected
    • Connected to github.com (13.229.188.59) port 443 (#0)
    • TLS disabled due to previous handshake failure
    • CAfile: /etc/pki/tls/certs/ca-bundle.crt CApath: none
    • NSS error -12286
    • Closing connection #0
    • SSL connect error curl: (35) SSL connect error

    after upgrading curl , libcurl and nss , git clone works fine again, so here it is. the update command is as follows

    sudo yum update -y nss curl libcurl

    0 讨论(0)
  • 2020-12-02 07:28

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

    0 讨论(0)
提交回复
热议问题