Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Break up git repo into multiple smaller ones

We have a big project which has developed a structure with many libraries with a hierarchical dependency structure.

Now, moving on to a different project, I would like to break this up into one repo per library and one or more project specific repos, but keeping the history. Effectively this means turning subdirectories of one big repo into separate repos with dependencies possibly handled via sub modules or some other appropriate mechanism. Is this kind of restructuring operation possible with git without too much pain?

like image 212
maddanio Avatar asked Dec 18 '25 15:12

maddanio


1 Answers

This depends. If you would like to track the new repository as a submodule and rewrite history to look like you were all along using the submodule, you would need to write a git filter-branch script to do that for said subdirectory. The tricky part would be to reflect branching and merging in the submodule as well.

If you would like to do this from now only, it would be easy to move the commits in the specific path to a new repository. Simply do a filter branch on a new branch and only include the history that involves changes to it. Make a new repository and fetch that branch only. You can now add this repository as a submodule and track subsequent changes from this point on.

like image 58
Adam Dymitruk Avatar answered Dec 21 '25 07:12

Adam Dymitruk