Last updated November 8, 2011.
Upon taking over maintainership of the Performance project, once started by kbahey, I was asked to migrate the Performance module from the Devel project in such a way that all development history regarding the Performance submodule was preserved.
kbahey figured there had to be a way to do this and, of course, git wouldn't be git if it was possible.
Since it's such a powerful git thing git can quite easily do, I decided to document the process using the above situation as an example. You can easily adjust (and improve please if possible ;-) the process for your own situation.
1. Clone all branches of devel (tell you later why not just the master :-s):
$ git clone --branch 5.x-1.x http://git.drupal.org/project/devel.git devel5f
$ git clone --branch 6.x-1.x http://git.drupal.org/project/devel.git devel6f
$ git clone --branch 7.x-1.x http://git.drupal.org/project/devel.git devel7f
2. Filter (hence the trailing f in the develXf folders) all branches to contain only the history concerning the performance subdir:
$ cd devel5f && git remote rm origin && git filter-branch --subdirectory-filter performance -- --all
$ cd ../devel6f && git remote rm origin && git filter-branch --subdirectory-filter performance -- --all
$ cd ../devel7f && git remote rm origin && git filter-branch --subdirectory-filter performance -- --all
git remote rm origin removes the remote link so as not to affect the remote repository. In this case just an extra security measure since we do not have rights there anyway as we did not clone the repository as an active user with the proper access rights.
3. Clone the Performance repository:
$ cd ..
$ git clone --branch master <username>@git.drupal.org:project/performance.git
4. Add the filtered devel repositories as remote branches:
$ cd performance
$ git remote add devel5f ../devel5f
$ git remote add devel6f ../devel6f
$ git remote add devel7f ../devel6f
5. Fetch all their data into the current repository and remove the branches as we no longer need them:
$ git fetch devel5f && git remote rm devel5f
$ git fetch devel6f && git remote rm devel6f
$ git fetch devel7f && git remote rm devel7f
Note: Doing all of this for each branch separately was the only way to really get all tags and thus all history. If I did it with just the 7.x or master branch, most of the 5.x and 6.x would come along as well, but not all of them, strangely enough.
6. Remove the tags we do not want as they are beyond the history we need to keep because Performace was removed since/in them:
$ git tag -d 6.x-1.26
$ git tag -d 6.x-1.25
$ git tag -d 7.x-1.2
$ git tag -d 7.x-1.1
7. Create new branches for D6 & D7 from latest tags:
$ git checkout 6.x-1.24
$ git checkout -b 6.x-1.x
$ git checkout 7.x-1.0
$ git checkout -b 7.x-1.x
8. Commit new branches to d.o:
$ git push origin 6.x-1.x
$ git push origin 7.x-1.x
9. Commit all tags in one go to d.o:
$ git push --tags
10. Marvel at the accomplishment ;-))