I have a rather large git repository that has a directory where I maintain library code. The directory contains a number of subdirectories.
repo
+--- lib
| +--- A
| +--- B
...
| +--- Z
Now let us assume that I want to open source subdirectories A,...,M
and keep subdirectories N,...,Z
close sourced. Let us also assume that I would like to:
- Keep
A,...,M
in a single open source repository. The reason for this is that the directoriesA,...,M
have interdependencies and it would be confusing to split them into individual repositories. - Keep the structure of my closed source repository intact. For example, I could create subdirectories
lib/pub
andlib/pvt
, but this would have cascading effects requiring changing references elsewhere or would require a lot of symlinks (lib/A -> lib/pub/A
). - Have a solution akin to
git subtree
where I can modify code either in my closed source repository or in the open source one and I can easily sync the changes between the two repositories.
I have searched for a solution in both stackoverflow and google, but there does not seem to be an obvious one. Conceptually this is something that git subtree
should be able to do, but it only works with a single subdirectory.
I have looked into the git-subtree
script with the intent of modifying it.
https://github.com/git/git/blob/master/contrib/subtree/git-subtree.sh
It appears to me that if I was to modify subtree_for_commit()
I should be able to convince git subtree split
to consider more than a single directory for splitting. But my knowledge of git is not enough to understand what the script is doing and modify it without breaking things.
If you have any solution for the above mentioned problem or any other pointers in modifying git-subtree
, please let me know.