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.
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.
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.
Finally, click on Authorize atlassian to authorize SourceTree to access your GitHub account.
Afterwards, you should see a successful message, Authentication OK. Then click on OK.
After this, you can view all your repository in SourceTree when you clicking on your remote account.
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.
Then, click on Generate in PuTTY Key Generator.
Move your mouse cursor within the blank space to continue the private and public key generation process.
After you done with the SSH key generation, set a password for your SSH key.
Then, save your public key 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.
Next, click on SSH and GPG keys to add New 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.
Now back to SourceTree, go to Tools and click on Launch SSH Agent.
Later, click on a small monitor icon in your taskbar.
As a result, the Pageant Key List will popup. Then, click on Add Key to add the private key you saved previously.
Now go back to your GitHub repository page and try to clone your repository with SSH way.
Finally, you will able to clone your own repository 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.