添加链接
link管理
链接快照平台
  • 输入网页链接,自动生成快照
  • 标签化管理网页链接
相关文章推荐
乐观的冲锋衣  ·  三星 Galaxy Z Fold5 | ...·  5 月前    · 
善良的芹菜  ·  如何从Google ...·  5 月前    · 

I've recently started to enable 2FA (Two Factor Authentication) on most of my online accounts, including GitLab . But what happen when you try to clone a repository against https after that?

When I tried the first time I run the usual git clone:

 git clone https://gitlab.com/username/project.git
    Enter fullscreen mode
    Exit fullscreen mode
Cloning into 'mypersonalbalance'...
remote: HTTP Basic: Access denied
remote: You must use a personal access token with 'read_repository' or 'write_repository' scope for Git over HTTP.
remote: You can generate one at https://gitlab.com/profile/personal_access_tokens
fatal: Authentication failed for 'https://gitlab.com/f.peluso/mypersonalbalance.git/'
    Enter fullscreen mode
    Exit fullscreen mode

I googled a little bit, finding that the problems was the 2 factor authentication, and then I found the following solution:

  • Log in into the GitLab account;
  • Go to the Settings section (at the moment, top right, hover the profile image and wait for the menu);
  • Go to Access Tokens;
  • Now here you can create a temporary token; if you need to pull/push you must enable read_repository and write_repository flags.
  • A token is shown in the page. Don't close or refresh the page, or you won't be able to retrieve the same token again!!!
  • Save the token somewhere safe if you need to use it more than once (I needed only once, so I just copypasted it, and then deleted it).
  • After these steps you can clone the repository using

    git clone https://oauth2:[email protected]/username/project.git
        Enter fullscreen mode
        Exit fullscreen mode
          

    Built on Forem — the open source software that powers DEV and other inclusive communities.

    Made with love and Ruby on Rails. DEV Community © 2016 - 2024.