Use a personal access token to access GitLab using SourceTree

Use a personal access token to access GitLab using SourceTree

Back in August 2018, the SourceTree blog announced that version 3.0 introduced support for a number of different Git hosts based on growing customer demand. One of the most requested hosts was

This tutorial shows you how to set up SourceTree with using a personal access token.

This option is excellent if you want to access your repositories on your work and personal PC and don’t want to bother managing SSH keys across PCs.

If your account uses Two-factor Authentication (2FA) you must use a personal access token as your password to clone repositories over HTTPS to your local PC environment.

Before you start

This tutorial was written in April 2021 using a MacBook Pro running macOS Big Sur. The procedures for adding an account to SourceTree should apply equally to Windows 10 users, however the procedure has not been tested or verified on this operating system.

Gather the following accounts and other information.

  • An account on

  • Your username. You can find this in your user profile below your name.

    Screenshot of the GitLab Account Settings menu open with the username highlighted
  • SourceTree installed with your Atlassian account connected and verified.

Create a personal access token in GitLab

To connect SourceTree with, you can either use SSH or create a personal access token. Personal access tokens let you authenticate with GitLab over HTTPS with 2FA.

To create a personal access token:

  1. Load to access your user profile settings page.

  2. In the side bar, click Access Tokens to load the Personal Access Tokens screen.

  3. Add a personal access token by completing the following fields:


    Add a short descriptive name for your token. For example, SourceTree Desktop.

    Expires at

    Leave the date field blank so the token never expires. Or if you prefer, select an expiry date you feel comfortable with.


    Select the api and read_user scopes for your token. This allows SourceTree to have full read and write permissions to your repositories and lets the app access your user account settings so it can add this information to commits.

    Your screen should look like this example.

    Screenshot of GitLab personal access token settings with api and read user scopes selected
  4. Click Create personal access token.

  5. Save the personal access token to a safe place (a secure password manager is recommmended).

    Screenshot of the created token
    This step is the last time you will have access to the personal access token. Make sure you save it now before continuing.

Configure the SourceTree account profile

Now you have created and saved the personal access token, you can configure SourceTree with this token and access your repositories.

To set up a account profile in SourceTree:

  1. Open the SourceTree  Preferences  Accounts screen.

  2. Click Add…​ to open the account options screen.

  3. Set the following options:


    Select from the list.


    Type your username (not your email) into the field.


    Paste your personal access token into the field.


    Select HTTPS from the list.

  4. Click Save.

  5. Close the Accounts screen.

Test the GitLab account by cloning a GitLab repository

To clone repositories from the remote host:

  1. In SourceTree, click the Remote option.

  2. Expand the GitLab group.

  3. Click the Clone link for the repository you want to clone.

  4. Check that the Clone a repository modal displays the https:// prefix in the Source URL field.

    Screenshot of the clone repository modal showing https protocol
  5. Click Clone to clone the selected repository to your local environment.


You have configured a account in SourceTree that uses a personal access token to authenticate with

comments powered by Disqus