I want to clone gitlab repository without prompt for my automation script, by using my private token from my gitlab account.
Can someone provide me a sample?
<You can do it like this:
git clone https://gitlab-ci-token:<private token>@git.example.com/myuser/myrepo.git
many answers above are close, but they get ~username
syntax for deploy
tokens incorrect. There are other types of tokens, but the deploy token
is what gitlab offers (circa 2020+ at least) per repo to allow customized access, including read-only.
from a repository
(or group
), find the settings
--> repository
--> deploy tokens
. Create a new one. A username
and token
field are created. The username
is NOT a fixed value by default; it's unique to this token.
git clone https://<your_deploy_token_username>:<the_token>@gitlab.com/your/repo/path.git
tested on gitlab.com public, free account.