How do I provide a username and password when running “git clone git@remote.git”?

后端 未结 10 2099
有刺的猬
有刺的猬 2020-11-22 07:00

I know how to provide a username and password to an HTTPS request like this:

git clone https://username:password@remote

But I\'d like to kn

10条回答
  •  栀梦
    栀梦 (楼主)
    2020-11-22 07:16

    Though there are many answers, myself facing the repeated issue when username or password has special characters in it.

    URL encode your username and password for git, then use it as part of URL itself (when there is no security concern).

    Say, URL encoded value of username

    'user+1' is user%2B1

    and URL encoded value of password

    'Welcome@1234' is Welcome%401234

    Then your GIT Clone URL would look like,

    git clone https://user%2B1:Welcome%401234@actual-git-url-for-the-repo works perfectly, whereas,

    git clone https://user+1:Welcome@1234@actual-git-url-for-the-repo gives you 403 errors

    Hope this helps.

    Just in case, want to URL encode online: https://www.urlencoder.org/

提交回复
热议问题