Frage

I am looking for a way to work with different GIT branches and have the Eclipse workspace in sync. with the directory structure of the GIT branches. In this case the branches will differ as projects have moved around from subdirectoris. To illustrate:

  • master
    • plugins
      • plugin1
      • plugin2
      • feature1
  • topic_organize
    • plugins
      • plugin1
      • plugin2
    • features
      • feature1

I think the current Egit solution is not workable. What it does it close projects which are not in the new branch. (When I switch branches in the cmd line, is even more horrific, Egit actually recreates the missing projects! in this case, when I switch to branch "topic_organize", the project feature1 in plugins will be recreated by EGit, my repo is automatically not clean which I sincerely despise, when switching to a branch).

What it doesn't do (and should do) is to start with a clean workspace, and import all the projects and organize them in working sets and on top load the appropriate target platform.

The consequence of not doing what is should is, that I have to 1) manually import missing projects, 2) remove projects created by EGit which are in my repo, but not imported in the workspace. 3) Create working sets if these differ between branches. (In my case the working sets, are equal to the sub-dirs in the repository). 4) Clean my GIT repo.

As a best-practise towards a full solution is to create a team project set. The working steps would be.

  1. Import your projects from GIT and add them to working sets corresponding to the directories in the GIT repo.

  2. Export a Team Project set to a special project. (Make sure the location of this project never moves in GIT).

  3. Commit this "team" project, so your GIT branch is clean.

  4. Clean your workspace. (I mean start with a clean workspace by removing all working sets and projects).

  5. Switch branch on the command line (You won't be able to switch with a clean workspace).

  6. Select file import, import Team Project Set (.psf) file. (Assuming you did step 1,2,3 for the other branch as well).

  7. tada your workspace is back with working sets and all projects open.

  8. Change your target platform if needed.

NOW MY QUESTION :P

Do I miss something? Is this there a way to clean the workspace in one go? Now I have to remove the working sets first, then the projects by selecting them one by one! (Perhaps I should switch the workspace as well?).

War es hilfreich?

Lösung

Considering the way Eclipse work, it has only one version of a project available in an Eclipse workspace at any time (because the id of a project is its... name)

When one needs to "switch branch", I always prefer having:!

  • multiple clones of the repo (one per branch, I rarely need more than 2)
  • multiple Eclipse workspaces

Switching branch means switching workspace and updating the branch you are in, in that workspace.

As the OP user2736833 comments below (using git remote):

git clone repo br_dir 
cd br_dir 
git checkout br 
cd repo 
git remote add -t br_dir br_repo ../br_dir

Then:

git fetch br_repo 
git checkout br
git merge br_repo/br
Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top