问题
I have two different bitbucket accounts set up. One is for work projects and one is for personal use. In BitBucket I have set up a repository in each of the accounts for different projects.
In SourceTree I have a few existing personal projects that are syncing up to my personal repository on SourceTree. In the left hand panel I can see my "Develop" branch for one of those personal projects and on the remote in BitBucket I can see the remote repo.
In SourceTree I don't see an obvious way to keep my two accounts separate. For example, I have added the work repo in SourceTree but when I try to commit an initial version of a work project it only gives me the option to commit my personal project branch.
How can I now add my work repo locally and sync only those work projects into repos on that work BitBucket account?
回答1:
For SourceTree 2.0.2+ on Mac only with GitHub accounts:
- Click from menu File-> New/Clone
- In the dialog click settings icon.
- In the resulting popup menu click Settings
- It brings a dialog with listing user accounts. Add your additional account to the list.
- Close the dialog.
- Click remote button (next to local) on the tool in image shown below.
All your added accounts will be listed and their respective repositories with button to clone.
Hope this helps.
回答2:
NOW on Windows, you do it in the Clone/Add/Create Repository dialog:
- Click the "Hosted Repositories" button (internet icon)
- Click "Edit Accounts"
- Click "Add"
回答3:
Well I have done this way:
- Click on Settings
- Click on Advance tab
- Enter your Full name and Email address (Email should be match with your Bitbucket account)
- Click on OK
- Click on Close (To close current window)
- Restart again
Note: You must have added account in Source tree. (Open Source tree -> Click on Setting icon < Right Top corner> -> Click Settings -> Add your Account -> Set as Default account)
Hope this would help you.
回答4:
In Windows, you can do it by following steps:
- Click on settings button ( right top corner). It will open dialog box.
- Click on Advanced tab.
- Uncheck the "Use global user settings".
- Now you can enter username and email id for corresponding repository.
- Click on OK to save changes.
回答5:
If I understand your question correctly, you still need to do a little bit more set of your bitBucket accounts.
You can also test the BitBucket server to see which account you are logging in with.
ssh -v git@bitbucket.org
This link help me, follow these instructions here and you should be successful.
The key part you need is in you .git/config.
You'll need separate entries for each.
Use different SSH keys for different accounts on the same Git hosting
回答6:
In Windows you may have more than one account (you can have even GitHub and BitBucket side by side). For example, assuming the account you have now in SourceTree is with BitBucket and you want to add your GitHub account to it as well, do the following:
- From menu, choose File->New/Clone
- In the Source Path/URL put the repository url for a repository you have on github
- Wait for a few seconds and it asks you for username/password. (first, buttons might be disabled for example for entering your password. So wait for a few seconds first)
- Add the new username and passowrd on github.
- Now if you like you can cancel the clone.
回答7:
For BitBucket account/repos, you can include the username you want to use as part of the git URL. SourceTree will then ask for the password for that username.
https://username@bitbucket.org/account/repo
回答8:
If you've already cloned a repository with ssh on the Mac version, and you want to change the account for it, you can do this by changing the host name of the remote.
If you've let SourceTree modify your ˜/.ssh/config
, then it will have added some entries starting with:
# --- Sourcetree Generated ---
Host <account name>-<service name>
...
Choose the <account name>-<service name>
combination that you want to use and modify the path of your repository (in Remote Settings). Your new path will be something like the following format:
git@<account name>-<service name>:<account name>/<repository name>.git
(Actually, you can use this solution for working copies not cloned by SourceTree too.)
回答9:
on windows the tool has a bug no matter what I've tried from within the tool it was always using a previews git account which was cached somewhere... so I searched all files where sourcetree was installed and I found a file C:\Users\WIDNOWS_USER\AppData\Local\Atlassian\SourceTree\userhosts there I had cached the old git user/account name and it was driving me nuts in the app. I updated this file, deleted the old account name and added the new one, restarted the tool and it started to work fine. there's also a file C:\Users\WIDNOWS_USER\AppData\Local\Atlassian\SourceTree\passwd check that one too and if your cached account with passwd is there too clean it out, do not add here anything, the app will do it first time when you enter your password for the new acccount
来源:https://stackoverflow.com/questions/19048618/how-to-work-with-two-different-bitbucket-accounts-in-sourcetree