I’ve had a goodle and a search on here but nothing seems to answer my question so here goes.
I have a git repository with the current folder structure
/app/folder/
/app/folder2/..
/app/bundles/bundle1
/app/bundles/bundle2
I’d like to turn every bundle in bundles into its own submodule, keeping all the version control history for the code in that bundle, keeping the directory layout exactly the same. The reason for this is I have another app where I want to use some of the bundles.
I had a go at using
git filter-branch --subdirectory-filter bundles/client -- --all
But this was not the right thing to do….
Any help would be greatly appreciated.
Actually, the use of –subdirectory-filter was exactly the thing to do, it is even given in the examples of filter-branch manpage. Of course, it will replace the currently active branch with a new one, containing the result of the operation. The original branch (the pointer to it) is usually saved in “refs/original/” (see –original option in the manpage).
You can copy the active branch somewhere else:
and restore the current branch
You can than export the active branch as a bundle, or fetch it directly in a submodule and remove the reference from the parent repository.
If the –all option to filter-branch was used, all branches suffer the fate of the active branch, so you have to repeat the copy operation for each.
Sadly, you cannot give the output branch name to filter-branch command. Might be worth a suggestion on Git mailing list.