SourceTree multiple branches

Hi,

I'm new to SourceTree. I would like cloning (on my local workstation) different branches (master and develop) from the same remote repo. How can I do this in SourceTree?

Thanks.
Guy
 

1 answer

You don't clone a branch, you clone the entire repository. Once you have a local repo, you can "check out" one branch at a time, but can switch as frequently as you want with or without access to the remote.

If you need to have working copies for two different branches at the same time, you'll need two local repositories. You can either have both clone the same remote repository to different local locations, or you can have your second local repo clone your first.

Hi Seth,

Thanks.

I performed "Clone from URL" and I get a copy (folders/files) of the "master" branch in my local git folder. In the "SourceTree" window I see: under BRANCHES master and under REMOTES develop - HEAD - master.

When I now right-click "develop" and select "Checkout" I see in my "SourceTree" window under BRANCHES develop and master; but I don't see in my local git repository adding any files of the develop branche?

My intentions are: not changing the source code from the remote repo but I would like having the code of the different branches locally (for local use in another app)?

Thanks.
Guy
 

When you check out a different branch, the files in your local folder should change, unless the contents of the two branches are identical. If that isn't happening, there may be something wrong with your local git setup. Compare the branches and identify one difference that should exist between the two, then check for that after checking out each branch. I still don't really understand what you're going for, but I don't need to. If you need access to both branches at the SAME TIME, you NEED two repositories. Otherwise, alternating checkouts should be sufficient.

My intentions are: not changing the source code from the remote repo but I would like having the code of the different branches locally (for local use in another app)?

I suppose I need to use your 2nd option:

If you need to have working copies for two different branches at the same time, you'll need two local repositories. You can either have both clone the same remote repository to different local locations, or you can have your second local repo clone your first.


Ok it works now. I created two repo clones the master branche called "abc-master" and the develop branche called "abc-develop". Both folders are now in my local git folder.

Thanks.

Guy


Suggest an answer

Log in or Sign up to answer
Atlassian Community Anniversary

Happy Anniversary, Atlassian Community!

This community is celebrating its one-year anniversary and Atlassian co-founder Mike Cannon-Brookes has all the feels.

Read more
Community showcase
Published Jan 23, 2018 in Sourcetree

Tip from the team: workflow and keyboard shortcuts

Supported Platforms macOS Sourcetree has a lot to offer and, like many developer tools, finding and using it all can be a challenge, especially for a new user. Everyone might not love ...

799 views 0 4
Read article

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you