How can pushing in the wrong order mess up all code? The worst thing I can imagine is pushing the superproject with a subproject update, but not pushing the subproject. That would end up with an unbuildable commit in the superproject, as you can never check out its associated commit from the subproject, but I don't see how that's close to "messing up all code".
Notice the post is 10 years old and some of the complaints can get solved with the config `submodule.recurse true` https://stackoverflow.com/a/49427199
There's actually a third alternative, called Git X-Modules (https://gitmodules.com). It's a tool to release the PIA submodules are causing, as described in may comment above :-)
In short, it takes all synchronization to the server's side. So you can combine repositories together in any way you like, and still work with a multi-module repository as if it was a regular one - no special commands, specific course of actions, etc.
Git X-Modules is a server-side app that syncs your project directories with other repositories. Think of it as a server-side alternative to Git Submodules.
Use Cases:
- Combine multiple projects and components into a single repository for cross-project development (like a monorepo, but keeping the original repositories up and running)
- Include parts of other projects into yours
- Share common assets across multiple projects
How it works:
- An X-Module is a regular directory. It’s synced on your Git server with an external repository.
- When an X-Module is updated the changes go to the external repository.
- When an external repository is updated the changes are applied to the X-Module.
- When there are two conflicting updates Git X-Modules applies one update and turns the other into a pull request
This tool is available as a free GitHub app. There's also an app for Bitbucket DataCenter (self-hosted).
Some of the real-life cases we've heard of:
- Code review team wants to see all changes made in various repositories, in one place
- A private project contains an open-source part, that is shared in a separate repository
- A library or component is maintained in a separate repository and shared between several projects
Both approaches have their good and bad sides. There is, however, a way to combine the advantages of both ways, having a monorepo synchronized with multiple individual repositories by Git X-Modules(https://gitmodules.com).
I am a part of the team behind it, so AMA about the tool :-)
It looks like the last step in missing: after discovering all disadvantages of submodules (they are in fact quite dangerous when working in a team), the author should have had switched to Git X-Modules[0] and use the same multi-monorepo approach without extra hassle :-)