How do I clone a gitlab project over https, now that gitlab requires 2fa?

  • Page Owner: Not Set
  • Last Reviewed: 2019-02-15

Gitlab won't let me clone with my username and password now that user logins require multifactor auth.

I know ssh cloning is preferred, but I presumably have a good excuse for https cloning. How do I do it?


Answer

Presuming you have a good reason to use HTTPS over SSH, you'll need to generate an Access Token.

Visit the access tokens page in Gitlab. Then generate a new token with only the api scope checked. You may name the token whatever you like. Save this token in a secure place such as 1Password or a sticky note on your monitor.

Then, when you checkout the project from gitlab, enter any username you like, and use the access token as your password.

Comments

  • Because tokens can be generated at any time, would it not be better to not save the token and just generate a new token when needed? Use it instead as a one time password? I know that when I do this the credentials get saved automatically in a terminal accessible auth manager.