Please use a newer Browser like Firefox or Chrome. We are ending support for this browser. Please upgrade your browser to improve your experience and security.

How to Connect GitHub with SourceTree

Tutorials ·

Today, we will learn how to connect GitHub with SourceTree. In this blog post, I am going to discuss two ways of connecting GitHub with SourceTree. You can choose any of these two methods based on your preference.

What Will We Learn (Method 1)

  • Connect GitHub with remote account

What Will We Learn (Method 2)

  • Create SSH Key
  • Connect GitHub Repository with SSH Key

Method 1: Connect with Remote Account via OAuth

The first method is connecting GitHub with remote account. You authorize SourceTree to connect your GitHub account with OAuth. This is the simplest method to connect GitHub with SourceTree.

Add Remote Account

First, click on Add an account.

Add an account

Then select GitHub for hosting services. Preferred protocol and authentication would leave it as default which is HTTPS and OAuth. Then click on Refresh OAuth Token.

Refresh OAuth Token

Eventually, it will open up a webpage automatically with browser and ask for login details for your GitHub account. If you had login to your GitHub account in this browser previously, this step will be skipped.

Login to GitHub

Finally, click on Authorize atlassian to authorize SourceTree to access your GitHub account.

Authorize Atlassian

Afterwards, you should see a successful message, Authentication OK. Then click on OK.

Authentication OK

After this, you can view all your repository in SourceTree when you clicking on your remote account.

Remote account connects GitHub with SourceTree successfully

Method 2: Connect with SSH Key

The second method is connecting GitHub with SSH Key. Firstly, you need to generate a pair of SSH key. They are private and public key. Public key is used on GitHub account. On the other hand, private key will be added to Pageant Key List in your computer.

Create SSH Key

In order to generate SSH key pair, go to Tools and click on Create or Import SSH Keys.

Create SSH key

Then, click on Generate in PuTTY Key Generator.

PuTTY Key Generator

Move your mouse cursor within the blank space to continue the private and public key generation process.

Keep moving cursor

After you done with the SSH key generation, set a password for your SSH key. 

Set a password for SSH key

Then, save your public key and private key.

Save public and private key

Don’t close your PuTTY Key Generator. Now login to your GitHub account, click on your avatar icon on the top right-hand side, then click on Settings.

Go to GitHub's settings

Next, click on SSH and GPG keys to add New SSH key.

Add SSH key

Give a title to your SSH key, and copy your public key from your PuTTY Key Generator into the Key’s field. After that, click on Add SSH Key.

Add SSH key to your GitHub account

Now back to SourceTree, go to Tools and click on Launch SSH Agent.

Launch SSH Agent

Later, click on a small monitor icon in your taskbar.

Pageant Key List in taskbar

As a result, the Pageant Key List will popup. Then, click on Add Key to add the private key you saved previously.

Add key to Pageant Key List

Now go back to your GitHub repository page and try to clone your repository with SSH way.

Clone with SSH

Finally, you will able to clone your own repository successfully.

Connect GitHub with SourceTree successfully

I hope my tutorial can help you on connecting GitHub with SourceTree successfully. If you have any questions or suggestions, please comment below. And you can like my Facebook page, A Word From Net to get notification on latest posts and to show support.

Leave a Reply

Your email address will not be published. Required fields are marked *