Posted on 19/04/2012. By Pete Otaqui.
There is a lot of great information on StackOverflow about splitting git trees into submodules. We followed this guide that suggests copying the repository and then using git-filter-branch .
We are in the situation where we had quite a lot of branches (around 30) that we wanted to maintain, and many of these included commits to the main repository and the directory that we were splitting off. We’ve discovered a few things along the way.
- Make sure you’ve done as much merging as you can, and minimise the number of branches you want to move across.
- Take this as blocking project, and assume other work can’t really continue until this change has made it to master.
- Apply this change to all active unmerged branches asap.
- Where branches have commits across the new submodule boundary, you may need to create and apply patches since ‘git merge’ won’t work across the boundary, but ‘diff’ and ‘patch’ can.