Guides for SE student projects »

Sourcetree Tips

Connecting Sourcetree to Your GitHub Account

SourceTree is a free GUI client for Git. One hurdle you might face while using Sourcetree is getting it to work with your GitHub account using GitHub's PAT (Personal Access Token). Given below are some things you can try if you encounter that problem.

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. In the SourceTree, choose Tools -> Options -> Authentication
  2. If any GitHub authentication methods are shown in that dialog, delete them.
  3. Click on Add, to add an authentication method.
  4. In the next dialog, choose:
    • Hosting Service: GitHub
    • Preferred Protocol: HTTPS
    • Authentication: Basic (different from option 1 above)
  5. Click on the Refresh Password button. When prompted, enter your usual GitHub username but give the PAT (the one you created in step 1) instead of the regular password.
  6. Now, your Sourcetree should be able to push code to a GitHub repo that you have write permission to.

If neither of the above works, you can try them again but first delete any GitHub credentials already saved by Windows. Here are the steps:

  1. Open the Windows Credential Manager.
  2. Delete any credentials related to GitHub (if the name mentions GitHub) in Web Credentials or Windows Credentials categories.

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.