How could I add a local submodule to a projet without actually cloning all the files it contain? I want to avoid duplicating my project's files locally.
I know this kind of thing can be achieved because when you clone a project that includes submodules, these are not cloned by default. You have to do it manually:
git clone url-of-repo-containing-submodules.git
git submodule init sub-mod
git submodule update --remote
Let say, I have a git repo meta-project with an out-source repo lib-sobmodule.
I could hack it to avoid file duplication:
cd /path/to/metaproject
git submodule add ../path/to/lib-sobmodule
git commit -m "lib-sobmodule added..."
git push
cd .. && rm -rf meta-project
git clone url-of-meta-project.git
Tadam! Files of lib-sobmodule are not duplicated on my desktop. But its not a nice solution as it exports then imports everything to/from a git remote...
Is there an option or a method that could prevent to clone a local project without having to duplicate all the files it contains?
Disclamer: This is almost a clone question of Is there a way to git submodule add
a repo without cloning it?. But as the answers are focused on the 30K git submodules requirement, they did not gave a satisfactory solution for the more common use case I describe here.