Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using GitLab token to clone without authentication

Tags:

git

gitlab

People also ask

Can you git clone from GitLab?

Clone with SSH Authenticate with GitLab by following the instructions in the SSH documentation. Go to your project's landing page and select Clone. Copy the URL for Clone with SSH. Open a terminal and go to the directory where you want to clone the files.


I know this is old but this is how you do it:

git clone https://oauth2:[email protected]/vendor/package.git


The gitlab has a lot of tokens:

  • Private token
  • Personal Access Token
  • CI/CD running token

I tested only the Personal Access Token using GitLab Community Edition 10.1.2, the example:

git clone https://gitlab-ci-token:${Personal Access Tokens}@gitlab.com/username/myrepo.git


git clone https://oauth2:${Personal Access Tokens}@gitlab.com/username/myrepo.git

or using username and password:

git clone https://${username}:${password}@gitlab.com/username/myrepo.git

or by input your password:

git clone https://${username}@gitlab.com/username/myrepo.git

But the private token seems can not work.


You can do it like this:

git clone https://gitlab-ci-token:<private token>@git.example.com/myuser/myrepo.git

Use the token instead of the password (the token needs to have "api" scope for clone to be allowed):

git clone https://username:[email protected]/user/repo.git

Tested against 11.0.0-ee.