0

How can we change switch branches on a terminal without switching the same on an IDE (say eclipse in my case)

I have a branch b1 which is currently on terminal. Open eclipse and see the same branch of code.

After a particular point, if I change the branch in terminal, say checkout b2, even eclipse is getting changed to b2 which should not be the case.

Venu
  • 1,513
  • 3
  • 19
  • 37
  • If the terminal and the IDE refer to the same work tree, it's almost impossible. But as I know, after you checkout branch2, the IDE is expected to prompt a dialogue to ask if you want to update the files. You could press No to keep its original contents. – ElpieKay Jun 12 '16 at 06:12
  • Yes, they refer to the same work tree. – Venu Jun 12 '16 at 06:15
  • As ElpieKay pointed out, it's almost impossible, since a git branch checkout changes the files in your directory. Since Eclipse sees those sames files, it will try to update them, or if you don't, I guess you'll end up with lots of swap files that you'll have to find a way to organize. Maybe keep two git directories, of the same repository though, and be mindful about committing, pushing and pulling in both? – curious_weather Jun 12 '16 at 06:19

1 Answers1

0

One possible workaround (especially if your .project is not versioned) is to:

  • have multiple working tree (one for b1, one for b2 in their own respective folders)
    It is possible since git 2.5 and the git worktree add command;
  • have a .project with different name in them like project_b1 and project_b2.

That way, you can actually import project_b1 and project_b2 in the Eclipse workspace, and you can work/compile concurrently on both projects.

Community
  • 1
  • 1
VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250