Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I git clone over https with a personal access token containing '/'?

I am trying to clone a repository from Bitbucket using a personal access token:

$ git clone https://{user}:{token}@bitbucket.repo/myrepo.git

Bitbucket just created four times in a row an access token containing a forward slash (/). Using such a token with git clone produces the following error:

fatal: unable to access 'https://{user}:{token}@bitbucket.repo/myrepo.git': URL using bad/illegal format or missing URL

The fifth token (without a /) worked. So, how can I git clone over https with a personal access token containing /?

like image 907
Ente Avatar asked Aug 30 '19 19:08

Ente


People also ask

How do I use a Git personal access token?

The first time you perform a push to GitHub, you are prompted for your username and password. Simply provide your GitHub username and the access token and your files are uploaded to GitHub. Use your GitHub personal access token as your password when you perform a git push to GitHub operation.

Where do I put a personal access token in GitHub?

In the upper-right corner of any page, click your profile photo, then click Settings. In the left sidebar, click Developer settings. In the left sidebar, click Personal access tokens.


2 Answers

Replace all / with their url-encoded representation %2F.

like image 50
Ente Avatar answered Oct 17 '22 13:10

Ente


When you generate token from bitbucket, it is more likely to generate special characters in the access token. While you pass these tokens as is with the reserved special characters, you will end up with an error. To overcome that, you need to replace the special characters with the corresponding characters.

!   #   $    &   '   (   )   *   +   ,   /   :   ;   =   ?   @   [   ]
%21 %23 %24 %26 %27 %28 %29 %2A %2B %2C %2F %3A %3B %3D %3F %40 %5B %5D

In your case, you need to replace / with %2F.

Ref: https://fabianlee.org/2016/09/07/git-calling-git-clone-using-password-with-special-character/

like image 20
Humble Bee Avatar answered Oct 17 '22 11:10

Humble Bee