DEV Community


Posted on

Submoduler: A tool to automatically keep git submodules updated through Python & Docker


Most of the comments I read online about git submodules go from:
"avoid them"
"never use submodules"
"use one big repo"

And after working with them for a year now I can understand why.

I would myself suggest to stay away from submodules, as they are not exactly immediate to understand and not a nice thing to maintain either.

That said, submodules can be useful at times.

For example:

  • You could have multiple repositories to which you want to provide the same developer scripts. One way of achieving this could be to have them live in a separate repository and add this as a submodule.
  • You have a very tight relationship between two repos, but at the same time you do not want (or can't) use a monorepo.

Submodules in a Nutshell

If you do not know what submodules are, they are simply links to a specific commit in another repository.

That's where the trick is.

Read again:
They are not links to another repository, they are links to a specific commit in another repository.

Let's imagine the current scenario:

  • We have repository_a and repository_b
  • We create a submodule of repository_b inside repository_a
  • All works good, we can see repository_a in Git and it gets pulled together with repository_b.

At some point, we might make a change inside repository_b.
We then fetch/pull inside repository_a, and surprise: the change is not there.

That's because, again, submodules point to a specific commit.

The process to update a submodule is quite straight forward:

cd repository_a
git submodule update --remote --recursive
Enter fullscreen mode Exit fullscreen mode

Great! The submodule is now updated and we see the latest changes we pushed to repository_b.

What about doing this every day, every time there's a change in repository_b?
What if repository_b is a submodule in 10/20/30 repositories?

Too much work.


That's where Submoduler comes in.

Submoduler is a simple Python app that can run in a Docker Container, and loops a list of repositories provided by the user to update all of their submodules in an automatic fashion.

You can find it here:

You can using by quickly pulling the Docker Image and running it with a simple configuration.yaml in which you can list the repositories to be updated as https urls together with options, and then run it passing a user and pat through the -env flag.

Hopefully this will be of some help to someone!

Top comments (0)