views:

339

answers:

1

I've been working on an Eclipse plug-in project for a while now, and I've run into a situation where I need to split the project up to seperate the test cases from the plug-in package. I'm using git as version control.

To describe this simply, I'm versioning the old project like this:

workspace/
  |
  +-- myplugin/
         |
         +-- .git/ <-- Here be the git repository
         |
         +-- /* Source code, project stuff, etc. */

…and I'm in the situation where I need to work the plugin tests in a seperate project (so that jUnit won't be needed as a required bundle with the plugin). And I'd like the repository to version everything in the workspace. Like this:

workspace/
  |
  +-- .git/ <-- The repository should be relocated here instead…
  |
  +-- myplugin/
  |      |
  |      +-- /* Source code, project stuff, etc. */
  |
  +-- myplugin-test/
         |
         +-- /* Unit tests and stuff… */

Is there a simple way to do this without losing the history of the old project?

+4  A: 

Here's the workflow in pseudocode:

cd workspace/myplugin
mkdir myplugin
git mv * myplugin # you might need to do that for all files/folders manualy
mkdir myplugin-test
# move/add files to myplugin-test
git commit -a -m "Reorganization"
cd workspace
mv myplugin myplugin_old
mv myplugin_old/* .
# you should end up with requested structure
Dev er dev
git mv * myplugin won't work - it says "fatal: can not move directory into itself, source=myplugin, destination=myplugin/myplugin". Use git mv $(git ls-files) myplugin/ instead.
rq
This looks good, but in the last step make sure you also get all files that begin with ".", like ".git" and ".gitignore" (* won't pick them up).
Pat Notz