Can't clone a github repo on Linux via HTTPS

前端 未结 9 1409
别跟我提以往
别跟我提以往 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:28

    I was able to get a git 1.7.1 to work after quite some time.

    First, I had to do disable SSL just so 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 push back. So i did

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

    to see the pull and push adresses:

    These must be modified with USERNAME@

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

    It will still prompt you for a password, which you could add with

    USERNAME:PASSWORD@github.....
    

    But dont do that, as you save your password in cleartext for easy theft.

    I had to do this combination since I could not get SSH to work due to firewall limitations.

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

    The answer was simple but not obvious:

    Instead of:

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

    do:

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

    or (insecure)

    git clone https://username:password@github.com/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.

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

    I had the same problem and error. In my case it was the https_proxy not set. Setting the https_proxy environment variable fixed the issue.

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

    Example:

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

    Hope this help somebody.

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