git clone over https 401 error and not asking for username or password

前端 未结 3 1000
小蘑菇
小蘑菇 2020-12-10 03:11

I have a private git repository on Codaset. Normally when I try to clone it over HTTPS on my Windows machine, it asks me for my username and password. When I try to clone it

相关标签:
3条回答
  • 2020-12-10 04:03

    You can do:

    git clone https://username@codaset.com/username/project_name.git destination_folder_name.git
    

    to make it prompt for password.

    0 讨论(0)
  • 2020-12-10 04:06

    I got it to work using this format:

    https://username:password@codaset.com/username/project_name.git destination_folder

    However according to these 2 posts, using that method could be a security problem:

    Can a username and password be sent safely over HTTPS via URL parameters?

    Username and password in https url

    0 讨论(0)
  • 2020-12-10 04:08

    To avoid having to enter a password at all (on Windows or Unix), you can:

    • check that HOME is defined (on Windows, it isn't by default)
    • setup a _netrc file with the following content:
        machine codaset.com
        login your_codaset_login
        password your_codaset_password
    

    Note: %HOME%\_netrc on Windows, $HOME/.netrc on Unix

    That way, when you are cloning your repo, instead of typing:

     git clone https://username@codaset.com/username/project_name.git destination_folder_name.git
    

    , you can remove the initial username:

    git clone https://codaset.com/username/project_name.git destination_folder_name.git
    

    and you won't have to enter a password.


    If you don't want to put your credentials (in particular your password) in plain text in an .netrc file, you can encrypt that netrc file with gpg: see "Is there a way to skip password typing when using https:// github"

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