I was part of a project that involved creating a redmine plugin with lot of features.
Now I want to take some of the features and turn them into individual plugins. For that I will create one separate git repository for each.
In that git repository I would like to have the intact history from the original git repository with only the files related to that feature.
Should I had the older repository as a remote and go through every commit manually, finding the ones that interest me, and committing them to the new repository?
Or is there another (more practical) way to do it?
The workflow on the old git repository was:
-
There was only the master branch;
-
Every time a milestone was completed
it was committed and pushed to the
remote;
Look at git-filter-branch(1) which is Git’s Swiss-army knife for automated rewriting of history and it certainly allows you to keep all commits touching a defined set of files (and drop everything else).
How to use it in detail, depends on your actual repository. If, for example, all the files you want to keep are already neatly contained in a subdirectory (say,
foobar), then the following would be sufficient:As an alternative, you could use the following to remove all files but the ones you want to keep from your repository: