git submodules with only 1 directory?
i need something like git submodules,开发者_运维问答 but the submodule have to be a directory of another project, rather than the entire project.
For example
The Submodule has:
somedir
files
dirs
someotherdir
files
dirs
thewanteddir
files
dir
I want to link thewanteddir
with another project
Is there anything that works like that?
If somedir
, someotherdir
and thewanteddir
are already part of one repo, then you cannot directly see just thewanteddir
(At best you would the 'theSubmoduleRootDir/thewanteddir
' anyway)
(And shallow clone submodules wouldn't isolate just one subdirectory)
The cleanest solution (but not the easiest one) would be to split that submodule repo in two, and make thewanteddir its own repo (which you can then add as a submodule)
You could use git-subtree
to split off a branch that just has the history of the thewanteddir
subdirectory, and then set that commit to be the submodule version. (You'd need to keep using git-subtree
to update the submodule, and merge back in changes.)
精彩评论