Guides for SE student projects »

Sourcetree

SourceTree is a free GUI client for Git.

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 connect to GitHub. In the dialog for connecting to GitHub,
    1. choose HTTPS as the protocol
    2. choose OAuth as the authentication method
    3. click the Refresh OAuth Token button so that SourceTree can obtain youn access token from GitHub. This usually opens up a Browser for you to sign in to GitHub. After you sign in to GitHub successfully, the installation can continue.
  4. In the Pick tools to download and install, you will be asked to choose whether to install Git and . You can unselect Mercurial, as we will be using Git instead.
  5. If prompted to set up an SSL key, you can click No, but you are free to set of an SSL key if you are familiar with SSL key usage.

Connecting Sourcetree to Your GitHub Account

If you did not connect your SourceTree to your GitHub account during the installation, or your current SourceTree-GitHub connection is not working, given below are how you can rectify it.

On Windows

Option 1:

  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 login to GitHub and to authorize Sourcetree accessing 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 2:

  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 (different from option 1 above)
  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 3:

  1. Open the Windows Credential Manager.
  2. For each credentials related to GitHub (if the name mentions GitHub) in 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 credential altogether and try Option 1 or 2 again.

On a Mac

Try this guide from Medium: Connecting Mac Sourcetree with your GitHub account.

If the above doesn't work, try this guide (also from Medium): Using Sourcetree to connect to GitHub without password.
It gives two methods. Recommended to try method 2 first.