Access GitHub Repositories with SourceTree and 2FA (2 Factor Authentication)

Many developers and organizations use GitHub as code repository. Similarly, many prefer to commit code in GitHub repositories using various commands. I personally think that using any kind of user interface for committing code and performing various GIT operations is much more simpler and productive.

SourceTree is one such Atlassian product. SourceTree is a free Git client and provides beautiful GUI that offers a visual representation for various Git repositories. For added security, you can enable 2FA (i.e. 2 Factor Authentication) for your GitHub account.

Configuring GitHub with SourceTree is very very simple. Here are the steps on MAC OS (steps on Windows OS are similar):

  • If you have not enabled 2FA:
    1. Open SourceTree and go to Preferences
    2. Select Accounts
    3. Click on Add button to add account
    4. On the pop-up window, select Host as “GitHub”
    5. Select Auth Type as “Basic”
    6. Type your GitHub username (not email)
    7. Type your password
    8. Select Protocol as HTTPS
    9. Click Save
    10. You can now clone GitHub repositories with above credentials
  • If you have enabled 2FA:
    1. Go to github.com and login to your account
    2. Go to Settings
    3. Select “Personal access tokens” link
    4. Now click on “Generate new token” button
    5. Provide some token description and select appropriate scopes
    6. Click on “Generate token” button
    7. Make sure you copy the generated token, otherwise you will not be able to get the same token again
    8. Open SourceTree and go to Preferences
    9. Select Accounts
    10. Click on Add button to add account
    11. On the pop-up window, select Host as “GitHub”
    12. Select Auth Type as “Basic”
    13. Type your GitHub username (not email)
    14. Type your password (this will be the generated token in above steps)
    15. Select Protocol as HTTPS
    16. Click Save
    17. You can now clone GitHub repositories with above credentials

There are many other products available in market with GitHub GUI feature, but I think SourceTree is one of the best.

Leave a Reply

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