Multiple working trees?

Is it possible to have two separate branches of the same repository open at the same time? I'd like to have an Xcode project open from one branch and the same Xcode project open but from another branch at the same time. So it would seem to me I would need two bookmarks specified. Both would point to the same repository but would allow me to work on two different branches of the same repository at the same time. Is this correct?

1 answer

1 accepted

Hey dkb,

We actually do this ourselves here to save switching branches. The way to do it is checkout multiple copies of your project, but each folder in your file system having different branches checked out. So essentially the same repository checked out multiple times to different locations. You can name the bookmark whatever you want which will give it the folder name to reflect the bookmark name allowing you to tell the difference. So for SourceTree we could give it names such as SourceTree_1_4 to indicate version 1.4. In Xcode you can quickly find out what version you're on (because it will just tell you your project name) by cmd + clicking on the very top middle where the project name is, and it will tell you the location of your project.

Hope that helps

Thanks. That answers my question perfectly. I wonder if there isn't a new feature lurking here. This concept could be better integrated into SourceTree. The ability for SourceTree to handle creation and switching between "independent" working trees.

The bookmarks reflect paths. I can see where you're going for hot-swapping between branches, but usually if you're doing that you need to do an update anyway as there's typically changes in other branches. Plus, the line between updating to a branch and switching between different directories becomes very blurred and can make it more confusing for the user. SourceTree reflects what Git/Mercurial does, and if we did what you suggested then it wouldn't be reflecting that functionality. Good idea otherwise though, it's just Git/Mercurial isn't designed to do this kind of thing :)

Git now provides a MUCH better way to do this and I would LOVE to see SourceTree support it.

Right now, I haven't the foggiest I deal what SourceTree is going to "see" if I create a second working tree.    I'd like to think it's exactly what I'd see today if there wasn't a second working tree.   That would be safe - but it would mean that I couldn't use SourceTree in the second working tree.

https://stacktoheap.com/blog/2016/01/19/using-multiple-worktrees-with-git/

Suggest an answer

Log in or Join to answer
Community showcase
Brian Ganninger
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 ...

274 views 0 3
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
Atlassian Team Tour

Join us on the Team Tour

We're bringing product updates and pro tips on teamwork to ten cities around the world.

Save your spot