Is it possible to have 2 local folders, each containing a different branch of the same repository?
Asked by thinsoldier:

<http://i.imgur.com/bn8xuw2.png>

I have 2 branches of a project (A \& B). I want to show the client 2 directions we could take the project in. I seem to only be able to switch the 1 project folder between the branches.

What I need is the ability to have a 2nd, completely different folder contain branch B.

1 folder for branch A - 1 folder for branch B.

That way I can show 1 thing on branch A then show the equivalent thing on branch B and have them side by side. With the current 1 folder - either A-mode or B-mode - I can't achieve this.

I don't want to **switch** branches within the existing folder. I want to keep branch A in the A folder then check out branch B into the B folder.

Is this possible?


Answers:
author: KieranA
body: Hi Maurice,

Sure, we do this all the time. For SourceTree I run two branches, one for the default branch (most recent changes) and one for specific versions such as 1.5.8.

All you have to do is checkout your repository twice (or copy one folder). So in my file system I have two folders in the same directory, one called "SourceTree" and the other "SourceTreeDefault" each of which has SourceTree checked out into them. This way, I can run two instances of the same application at the same time if I want to. In each folder I have a different branch checked out. Remember that checking out a branch has nothing really to do with the remote, it's to do with your local working copy and what you've chosen to checkout.

Remember that anything which is committed and pushed in one of the repo's will be pullable in the other anyway, so they can stay in sync.

If I were you, I'd just checkout your remote to another folder in the same parent directory as your existing repository (with a different repo/folder name), then just run both projects by whatever means you're displaying them. If it's a web server you can specify a port to run them on, and if it's an application then two instances would run anyway.

Hope that helps.

comments: author: thinsoldier
body: Thanks Keiran
> If I were you, I'd just checkout your remote to another folder in the same parent directory as your existing repository (with a different repo/folder name)

I eventually realized I could do this. I was hoping there was a way to just duplicate the existing working copy folder without needing to download the files from the remote origin again.

<http://i.imgur.com/cV9aBOj.png>

Does this look like what you've described or is there some other way that doesn't involving having to download everything all over again?


author: Shreyas Belle
body: I know this is an old question but there is a better way to do this now. See [this link](https://stacktoheap.com/blog/2016/01/19/using-multiple-worktrees-with-git/). It describes briefly how to use "git worktree". AFAIK Sourtree doesn't have any support for worktrees yet.

comments: author: martin.bjorcke
body: The original context is about a temporary demo. To me the obvious simple solution is to copy the working folder in file explorer and then in Sourcetree switch the working folder to the other branch. Discard the copy after demo.