Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Open two GIT branches in two separate IDE instances?

We are migrating from Mercurial to GIT.

With Mercurial we have separate repositories compared to one repo with separate branches in GIT.

Thus with Mercurial it's straightforward to open two separate repos in two separate instances of your IDE. How can you do this with GIT as there is (I believe) only one branch current at a time in a GIT repo?

Note: this similar ticket refers to opening two branches in the same IDE. The difference with this question is we're happy to open them in two separate IDE instances. Though I'm guessing the answer is the same - you can't do it.

like image 451
Marcus Leon Avatar asked Jun 22 '15 16:06

Marcus Leon


People also ask

Can I have two git branches open?

You can have many branches in your repository, but only one of these will be "checked out" as the working-tree so that you can work on it and make changes. git worktree adds the concept of additional working trees. This means you can have two (or more) branches checked-out at once.

How do I open two Visual Studio instances with the same git projects and different branches?

By utilising the git worktree command, you can create a second worktree for the same repository in a different directory. You can then open that work tree in visual studio to have two different branches checked out. where is the branch you want checked out in the new work tree.

Can I open two branches in Intellij?

You are correct: there is only one active branch at a time. The best you can do is to clone the repository twice on your local machine into two different directories, and then simply open up the appropriate directory in each IDE instance.

How do I open a different branch in git?

New Branches The git branch command can be used to create a new branch. When you want to start a new feature, you create a new branch off main using git branch new_branch . Once created you can then use git checkout new_branch to switch to that branch.


2 Answers

You are correct: there is only one active branch at a time. The best you can do is to clone the repository twice on your local machine into two different directories, and then simply open up the appropriate directory in each IDE instance.

like image 128
David Deutsch Avatar answered Sep 21 '22 03:09

David Deutsch


After making the two clones as David Deutsch suggested, I recommend picking one as primary and creating a symbolic link to the .idea directory from the secondary clone to the primary clone. This way you will have the same config in all clones.

ln -s primary_clone/.idea secondary_clone/.idea 

This assumes you use the .idea project config format and that you do not check config to the repository (in that case you are obviously all set from the get go)

it mostly works, only sometimes Idea prompts you with dialog box to reload other projects if you change some setting in the currently active one. You can refuse, though.

like image 42
user7610 Avatar answered Sep 19 '22 03:09

user7610