Connect SourceTree to 2-factor enabled GitHub

Bjørn Sigurd Johansen July 7, 2021

Plase provide a detailed summary of how to connect SourceTree to 2-factor enabled GitHub.

2 answers

1 accepted

1 vote
Answer accepted
Bjørn Sigurd Johansen July 9, 2021

I finally made it work.  I will try to summarize as best I can for others needing SourceTree to connect to GIT using 2-factor authentication (2FA):

  1. SourceTree: Tools > Options > Authentication:  Delete as many password accounts as you are able to delete.  Try deleting at least twice for those accounts that are hard to delete.

  2. Close SourceTree.

  3. Windows: Enter Control Panel > User Accounts > Manage Windows Credentials.  Delete all "Git-look-alike" credentials, i.e. the credentials in SourceTree: Tools > Options > Authentication that you were not able to delete.

  4. GitHub:  Set up 2FA.  I used SMS-verification.  Google a bit and you will find a guide.  This step was quite straight-forward.

  5. GitHub:  Create a token: Log in to GitHub, press user drop down arrow at upper right corner, choose 'Settings', choose 'Developer settings', choose 'Personal access tokens', choose 'Generate new token'.  I gave the new token access rights to everything.  Save the token.  My token was a string consisting of 40 characters.

  6. SourceTree: Clear all saved password:  Windows: Go to C:\Users\USERNAME\AppData\Local\Atlassian\SourceTree and remove the 'passwd' file.  The purpose of this step, is to force SourceTree to ask for password in next step.

  7. SourceTree: Open SourceTree and do a Pull Request. SourceTree will now ask for password.  Use the token from (5) as password.
Charlie Misonne
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
July 9, 2021

I'm glad you sorted it out and thanks for documenting the steps for other community members!

You can mark your own answser as accepted if you want to.

0 votes
Charlie Misonne
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
July 8, 2021

Hi again,

I read your post while answering your other one.

I haven't used SourceTree myself since a while. But I found this article in the documentation: Two-Factor Authentication (2FA) with GitHub in SourceTree 

The article says: "For versions earlier than SourceTree 2.4 for Mac and SourceTree 1.10 for Windows." SO I'm not sure if it will be of any help.
But I hope it points you in the right direction.

UPDATE:

I found the information for recent versions.

Apparenltly newer versions support the Windows Credential Manager which supports 2FA.
So you'll need to use that tool.
See more on SourceTree for Windows 1.10.0-* authentication and accounts updates 

Bjørn Sigurd Johansen July 8, 2021

Thanks for answering.  Before installing a new password manager, i tried https://confluence.atlassian.com/sourcetreekb/two-factor-authentication-2fa-with-github-in-sourcetree-402033499.html

But, unfortunatively, SourceTree seems to be extremely buggy in its Tools > Options > Authentication window:

  • NOT WORKING: Deletion of any password account set as "default account".
  • NOT WORKING: Editing any password account set as "default account".  (If trying to edit, the current passord account is not changed, but a new password account is created).
  • UNSTABLE:  Deleting password account not set as default account.  (Seems to me as if the *second* attempt to delete account normally works).
Bjørn Sigurd Johansen July 8, 2021

ALSO NOT WORKING:

  • If a new password account is created, I am not able to set it as default. 

As far as I can see, this effectively means that it is impossible to edit a default password account(!)

 

I am using latest SourceTree version 3.4.5.

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events