当我尝试添加我的 gitlab 帐户时,SourceTree 给我一个登录错误

SourceTree gives me a login Error when I try to add my gitlab account

我想将我的 gitlab 帐户添加到 sourcetree。在首选项 -> 帐户中,我尝试了 'add' 按钮

host: GitLab.com
Auth type: greyed out
username xxxxxx
password: xxxxxx
protocol: https

等我去救。我收到一个弹出屏幕,上面写着:"We couldn't connect to GitLab with your (XXXXXX) credentials. Check your username and try the password again."

我已经仔细检查了用户名和密码。

GitLab 论坛上有人最近similar issue,他们记录了解决它的步骤:

I eventually noticed that for github and bitbucket the credentials are through "Oauth", and for GitLab "Personal access token". I had generated yesterday a toke, but hadn't used anywhere.

Steps to add a repo from GitLab on SourceTree:

  1. On your browser, go to your account and > User settings > Personal Access Tokens (https://gitlab.com/profile/personal_access_tokens)
  2. Generate and copy the token
  3. On Sourcetree,

    a) leave https as preferred protocol

    b) click on Refresh Personal Access Token

    c) type your username

    d) use the copied token as password

参考下图

我为@David 的回答增加了一些优势。按照他提到的任何步骤进行操作,但请记住在创建个人令牌时 select 所有范围。

问题已解决

解决方案是(在 Mac 上):

  • 从 GitLab 撤销旧的访问令牌(它只有下一个范围:read_repository、write_repository)
  • 生成具有下一个范围的新访问令牌:api、read_user、read_repository、write_repository(奇怪的是,对于其他同事来说,它只适用于 read_repository, write_repository)
  • 在 SourceTree 上:转到 SourceTree -> 首选项 -> 帐户 -> 添加 -> fill-in 如下图所示的详细信息(对于密码,请使用访问令牌):

在此之后,我能够克隆存储库(“从 URL 克隆”)。

此外,这个 link 启发了我:https://www.awordfromnet.com/access-gitlab-via-sourcetree-updated/