Problem setup, skip to linebreak for question.
I am working on projectA that has it's own git repo. This projectA has some optional tools in projectB that is its own separate git repo. From what I understand this sounds like a git submodule situation, making projectB a submodule of projectA.
To set this up I use git submodule add projectB
. This creates a sub-directory in projectA that acts like a link to projectB, with that information saved in .gitmodule
. You need to commit both this file and the "subdirectory". I can continue to develop on projectA without paying any attention to projectB. When I make updates to projectB and push them, I can update projectB within projectA by using git submodule update --remote
. This alters the projectB subdirectory in projectA, both by updating the files inside to current version of projectB (not tracked by projectA) and the subdirectory file itself (tracked by projectA).
Now suppose a third user wants to take projectA and make projectC, but doesn't need projectB. They use git clone projectA
, they get all of projectA and the .gitmodule
and an empty subdirectory for projectB. I would like them to still get .gitmodule
so that they have the option in the future, but is it possible so that they don't get the empty subdirectory for projectB?
My question is it possible to hide the subdirectory for a submodule projectB in projectA before the user does a git submodule init
> git submodule update
?
I'm afraid this isn't possible because that subdirectory is actually a special git file that tells which commit to get of projectB, which I would have thought was saved in .gitmodule
. I'm interested if there is a better method for what I want to accomplish or any git hacks.