I have two code libraries A and B and have started developing an application M. All three of these are stored in their own repository.
My problem is that I have a dependency such that A uses submodule B, but M uses both submodules A and B.
As far as I can tell I'll have two copies of the same submodule B for the same main project. But it would never make sense (in this setup) for them to be different, as they represent the same library in the same application.
Is there a way to work around this, so that when I work on M I have only one copy of A and B?
In most cases, Git submodules are used when your project becomes more complex, and while your project depends on the main Git repository, you might want to keep their change history separate. Using the above as an example, the Room repository depends on the House repository, but they operate separately.
Git submodules may look powerful or cool upfront, but for all the reasons above it is a bad idea to share code using submodules, especially when the code changes frequently. It will be much worse when you have more and more developers working on the same repos.
git submodule sync synchronizes all submodules while git submodule sync -- A synchronizes submodule "A" only. If --recursive is specified, this command will recurse into the registered submodules, and sync any nested submodules within.
M--/
|-- A
| |-- B
|
|-- B
Just remove M/B
submodule from M
, and keep/use M/A/B
.
The reasons:
A
submodule(a independent repository), it must needs B
for something.M
repository, you can teach it to use M/A/B
.If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With