Is there an easier way to integrate a subdirectory of an existing repository into another repository than sparse checkouts + subtree merge?
I have an existing code base (fairly large, being worked on by about a dozen developers) with a structure much like
ourproject/src/gui ourproject/src/libs ourproject/src/shared ourproject/src/backend ourproject/tests ...
I would like to reuse most files beneath
src/shared in a separate project, hosted in a separate Git repository – preferably in a subdirectory, something like
- Merging two git repositories as different versions
- What is the svn:mergeinfo equivalent for git?
- Macbook overheat while merging conflicts Android Studio
- How to fork two git branches around failed merge
- Concatenate CVS and Git repos into one Git repo
- Reason for Subversion merge variations
Now, ideally I could move that common code into a separate repository and then use Git submodules or Git
subtree to include that common repository into both
ourproject is being worked on by a lot of people and I’d like it to remain the “main” source of the files such that others don’t have to adjust their workflow.
Hence, to implement this, I’m planning to use an intermediate repository which holds a sparse checkout of the
ourproject repository (sparse in the sense that it only holds the
src/shared subdirectory). I’ll then use a
subtree merge of that intermediate directory into the
However, having this intermediate repository is inconvenient and requires additional work for keeping it in sync. Is there a way to maybe combine the two such that I can do a subtree merge which only considers files beneath certain directories? Maybe a combination of a subtree merge and something built on