How to work with two different BitBucket accounts in SourceTree

前端 未结 9 428
天命终不由人
天命终不由人 2021-02-01 13:00

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 diffe

相关标签:
9条回答
  • 2021-02-01 13:24

    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.)

    0 讨论(0)
  • 2021-02-01 13:30

    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
    
    0 讨论(0)
  • 2021-02-01 13:34

    For SourceTree 2.0.2+ on Mac only with GitHub accounts:

    1. Click from menu File-> New/Clone
    2. In the dialog click settings icon.

    1. In the resulting popup menu click Settings
    2. It brings a dialog with listing user accounts. Add your additional account to the list.
    3. Close the dialog.
    4. 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.

    0 讨论(0)
  • 2021-02-01 13:36

    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

    0 讨论(0)
  • 2021-02-01 13:37

    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:

    1. From menu, choose File->New/Clone
    2. In the Source Path/URL put the repository url for a repository you have on github
    3. 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)
    4. Add the new username and passowrd on github.
    5. Now if you like you can cancel the clone.
    0 讨论(0)
  • 2021-02-01 13:38

    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

    0 讨论(0)
提交回复
热议问题