Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Gitlab clone private repo using api

Tags:

gitlab

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

Trying to clone private repository I have error " fatal: Authentication failed "

What am I doing wrong?

like image 691
bit Avatar asked Mar 19 '16 17:03

bit


People also ask

Can you clone a private repository GitLab?

make sure that you have added ssh key in your system. Follow this : https://gitlab.com/profile/keys . Once added run the above command. It will prompt for your gitlab username and password and on authentication, it will be cloned.


Video Answer


1 Answers

Make sure you have created a Personal Access Token on your Gitlab account with access to api scope. Also, the token must be not expired.

I used this and worked for me:

git clone https://gitlab.com:<personal_access_token>@gitlab.com/user/repo.git' 

FYI: I haven't set up Two-Factor Authentication (2FA), maybe this could be your problem if you have set 2FA in your account.

like image 106
adefelicibus Avatar answered Nov 26 '22 23:11

adefelicibus