Multiple Git Branches in Multiple Eclipse Projects

We’re in the process of converting from Subversion to Git and one thing that I’m struggling with in Git is the method of switching branches.

My understanding is that at both at the command line and using EGit in Eclipse that switching to a different branch replaces the contents of the Eclipse workspace folder with that of the desired branch. This implies only one branch can be open at any one time.

  • How to have Heroku build my development branch on a staging server?
  • What will happen if I delete a branch on my git repo and someone try to push a commit to it?
  • Remove experimental branch
  • Git: List git branches, sort by (and show) date
  • Git: Adding the full tree of files to the master
  • How to work with current working copy when moving to old branch in GIT?
  • In SVN I could arrange my Eclipse workspace similar to:

    Workspace/
       Project1Branch/
       Project2Branch/
       Project3/
       Project4Branch/
    

    Is it possible to have multiple Git branches open at the same time in the same Eclipse/Egit workspace ( or any other environment for that matter )?

  • Need GitBlit groovy hook which push changed to other Gitblit server repo
  • Git Svn Fetch More Revisions
  • Undoing changes to specific files in old commits, leaving no trace of them
  • How do I go to the next conflict in the Xcode merge tool?
  • Git gui here and bash not showing on other folders in windows
  • Find if my branch conflicts with any remote branch
  • 3 Solutions collect form web for “Multiple Git Branches in Multiple Eclipse Projects”

    After much testing and a sanity check from @MarkLeightonFisher it seems it is not possible to have multiple Git branches open in the same Eclipse workspace at the same time.

    Indeed you can’t import multiple branches from the same git repository into the workspace, because it only has one working directory which can contain only one checked branch.
    Here’s a very reasonable workaround that accommodates this feature of git (I do it and it works well):
    Clone the git repository in a second directory (or 3rd or 4th even), then change the name of the project manually by editing .project and changing the <name> element.
    You can now import this project alongside the original, and work on multiple branches at the same time in the same workspace.
    Caveat: Get very friendly with the “Close Project” menu item so you can avoid cross-editing (it gets confusing sometimes when you have many source windows open with the same file name…)

    Actually i managed to do it :

    You can have multiple workspaces for one git repository : this is called “worktree”. (limitation is that for obvious reason, you can’t checkout same local branch in 2 different work trees. Well, you shouldn’t, but some commands may lead you to be in such situation.)

    https://git-scm.com/docs/git-worktree

    Then you can create one eclipse-workspace for each of your work-tree.

    Git Baby is a git and github fan, let's start git clone.