Create a personal access token by following
Using the personal access token to authenticate, lets clone a repository.
Form your url
as shown below. Replace the personal_token
with the token you have got.
# To clone using personal token
git clone https://oauth2:personal_token@gitlab.com/username/project.git
If the project is already cloned and you have done few commits already by painstakingly providing the login and token every time then do this:
- Open the file
.git/config
invscode
or any editor you prefer - Change the
url
as show below with your personal access token
[remote "origin"]
url = https://oauth2:1AbCDeF_g2HIJKLMNOPqr@gitlab.com/yourusername/project.git
fetch = +refs/heads/*:refs/remotes/origin/*
For a more robust solution look at A function to clone git repository using gitlab personal access token
Top comments (1)
Thank you! this helped me to set it up correctly, couldn't find good information about how to use it well.