Connect SourceTree to 2-factor enabled GitHub
Asked by Bj?rn Sigurd Johansen:

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


Answers:
author: Bj?rn Sigurd Johansen
body: 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.*

comments: author: Charlie Misonne
body: 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.


author: Charlie Misonne
body: Hi again,

I read your post while answering your [other one](https://community.atlassian.com/t5/Sourcetree-questions/IS-SOURCETREE-SUPPORT-DOWN/qaq-p/1744423#U1744897).

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](https://confluence.atlassian.com/sourcetreekb/two-factor-authentication-2fa-with-github-in-sourcetree-402033499.html)

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](https://confluence.atlassian.com/sourcetreekb/sourcetree-for-windows-1-10-0-authentication-and-accounts-updates-867186698.html)

comments: author: Bj?rn Sigurd Johansen
body: 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).


author: Bj?rn Sigurd Johansen
body: 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.