SourceTree multiple branches

Guy Dillen October 12, 2014

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

1 vote
Seth
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
October 12, 2014

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.

Guy Dillen October 12, 2014

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
 

Seth
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
October 12, 2014

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.

Guy Dillen October 12, 2014

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
TAGS
AUG Leaders

Atlassian Community Events