Guides for SE student projects »

Sourcetree

SourceTree is a free GUI client for Git. In this guide, we assume you are using it with a GitHub account.

Installation

  1. Download Sourcetree from their website and run it.
  2. When prompted to Login to your Atlassian account, you can try to skip that step. If the installer doesn't allow skipping, you can create an Atlassian account as directed.
  3. In the next step, you will be prompted to Connect an Account. Choose to skip (we'll be connecting Sourcetree to GitHub later).
  4. In the Pick tools to download and install, you will be asked to choose whether to install Git and . Unselect Mercurial. Assuming you have installed Git already, when prompted, choose to use the system Git instead of the Git that comes with Sourcetree.
  5. If prompted to set up an SSL key, click No unless you are already familiar with SSL key usage.
  6. Next, connect Sourcetree to your GitHub account as explained below.

Connecting Sourcetree to Your GitHub Account

On Windows

Option 1: This is the recommended option, as it caters for both basic and advanced usage.

  1. Create a classic (not fine-grained) GitHub Personal Access Token (PAT), by following the instructions here.
    When asked to select the scope of the PAT, you can choose the repo option and the workflow option.
  2. In the Sourcetree, choose Tools -> Options -> Authentication
  3. If any GitHub authentication methods are shown in that dialog, delete them.
  4. Click on Add, to add an authentication method.
  5. In the next dialog, choose:
    • Hosting Service: GitHub
    • Preferred Protocol: HTTPS
    • Authentication: Personal Access Token
  6. Click on the Refresh Personal Access Token button. When prompted, enter your usual GitHub username but give the PAT (the one you created in step 1) instead of the regular password.
  7. Now, your Sourcetree should be able to push code to a GitHub repo that you have write permission to.

Option 2: This option is good enough for basic usage.

  1. Authenticate with your default browser on your GitHub account with your normal GitHub username/password.
  2. In the SourceTree, choose Tools -> Options -> Authentication
  3. If any GitHub authentication methods are shown in that dialog, delete them.
  4. Click on Add, to add an authentication method.
  5. In the next dialog, choose:
    • Hosting Service: GitHub
    • Preferred Protocol: HTTPS
    • Authentication: OAuth
  6. Click on the Refresh OAuth token button.
    If a browser window pops up and asks you to log in to GitHub and to authorize Sourcetree to access your GitHub account, do so.
  7. Now, your Sourcetree should be able to push code to a GitHub repo that you have write permission to.

Option 3:

  1. Open the Windows Credential Manager.
  2. For each credential related to GitHub (if the name mentions GitHub) in the Web Credentials or Windows Credentials categories,
    (a) edit it and replace the password field with a GitHub PAT.
    (b) If the above didn't work, delete those credentials altogether and try Option 1 or 2 again.

On a Mac

Here are two options for connecting Sourcetree with your GitHub account. Both require creating a Personal Access Token (PAT) at some point. When you create a PAT, we recommend that you tick both repo and workflow checkboxes.

  • Option 1: Try the steps given in this YouTube guide from Nick Graham:

Caching GitHub credentials

If you are prompted to enter GitHub credentials every time you connect to GitHub using Sourcetree, you can cache GitHub credentials by following the guide given here (recommended: use the Git Credentials Manager option, not the GitHub CLI option).