How to add more than one Github account to sourcetree
Asked by Bart-Jan van Hummel:

Lateley I have a lot of problems with having more than one github account in sourcetree. I am using two github accounts (one private one for work) and one Bitbucket account.   

I am using ssh to connect to the accounts. Where Bitbucket is working fine, and depending on which github account I add first, One github account seems to work OK, it will not show the repositories. The other account shows all repositories but is not able to download any because it somehow looks at the account I added first.   

I have tried several things, for fixing this.   
I first started out with a fresh install of sourcetree (mac) and a new set of SSH keys.   
Then adding the accounts but this did not help.  

Then I set up a personal access token to one of the github accounts and started to use the basic auth type and not OAuth this did not help either.  

I also saw that sourcetree does not allow you to select your own SSH key, and keeps on using the wrong one. I moved the one it found so it could not find it anymore.   
Hoping it would find the correct file, but now it cannot find the other file which is added to GitHub. So I generated a new one in Sourcetree and added it to GitHub.   

This did not work either, cloning a repository from this account still gets confused with the wrong login.   

Errors found are:  

ERROR: Repository not found.  
fatal: Could not read from remote repository.  

Please make sure you have the correct access rights  
and the repository exists.  
ERROR: Repository not found.  
fatal: Could not read from remote repository.

Please make sure you have the correct access rights  
and the repository exists.  
origin git@github.com:\*/\*.git (fetch) // note this is the wrong account

<br />

<br />

I am out of idea's and starting to believe I should not be using sourcetree anymore.  
It is at least too much time consuming to be bothered by it every time.   

I hope somebody has a good solution for this, as the interface is easy and helpful

UPDATE:   
It also seems like it, that Sourcetree is having some sort of cache.  
After I added a new ssh file to Github, removing the old one from the config file in the .ssh directory and removing the ssh file from the .ssh directory it still seems to want to add that specific ssh file.   

I removed Sourcetree all together, also removing files that where associated with it.   
After reinstalling, it still seemed to have my account data in there.   
So far for a 'clean' install.   
Thus I followed these steps: <https://community.atlassian.com/t5/Sourcetree-questions/How-do-I-fully-remove-SourceTree-so-that-I-can-do-a-quot-fresh/qaq-p/605355>  

After reinstalling still the same 'wrong' ssh keys where found and used by sourcetree.  
The worst part is, that I cannot set my own SSH file. I cannot choose it. Sourcertree just tells me that I need that file (somewhat frustrating).   

So I am trying again, but now with rebooting my computer after removing all files.   


Answers:
author: Bart-Jan van Hummel
body: After removing and re-installing several times the problems are still there.   
As it seems nobody has answer it looks like I need to start working with another application.


author: fbartram
body: Hi,

This not an answer as I am also having this problem of trying to add multiple SSH-based BitBucket accounts.

It looks like SourceTree only looks at the default \`id_rsa\` file pair in \`\~/.ssh\`.

SourceTree doesn't appear to be reading the \`\~/.ssh/config\` file for the \`IdentityFile\` parameter for the corresponding \`Host\`.

We need some way to associate the correct id_rsa file pair with the corresponding account.


author: Naresh S V
body: Hi,

When you're cloning the projects from two GitHub accounts, you also need to map those accounts in the Sourcetree before cloning the repository. Once you clone the repo from account 1, switch to the another account and then clone from account 2.


author: Bart-Jan van Hummel
body: It also seems like it, that Sourcetree is having some sort of cache.  
After I added a new ssh file to Github, removing the old one from the config file in the .ssh directory and removing the ssh file from the .ssh directory it still seems to want to add that specific ssh file.   

I removed Sourcetree all together, also removing files that where associated with it.   
After reinstalling, it still seemed to have my account data in there.   
So far for a 'clean' install.   
Thus I followed these steps: <https://community.atlassian.com/t5/Sourcetree-questions/How-do-I-fully-remove-SourceTree-so-that-I-can-do-a-quot-fresh/qaq-p/605355>  

After reinstalling still the same 'wrong' ssh keys where found and used by sourcetree.  
The worst part is, that I cannot set my own SSH file. I cannot choose it. Sourcertree just tells me that I need that file (somewhat frustrating).   

So I am trying again, but now with rebooting my computer after removing all files.   


Tags: github