How to manage multiple repositories

13 Apr 2018 | 2 min read

pattern/design file

The Problem

Our projects start with 2–3 repositories and quickly grow to 5–10 or more. There are several developers working on modules, front-end or backend services and you may not be responsible or aware of what’s going on in the other repositories, but you still need everything up-to-date on your laptop to run and test the whole architecture.

Our solution

We initially looked into “monorepo” tools like Lerna, but we found them to be overly complex and storing everything in “packages” didn’t feel right. The one problem we wanted to solve is keeping a few folders updated. The first thing we did was to create a “root level” repository, we either call that “hq” or the same name as the organisation/product we want to build. This repo we clone locally and add a .gitignore:


This ignores all contents in that repo except bin and Afterwards we clone all related repositories for that project into the root folder.

The interesting part happens in bin/:

The script loops through every folder and first prints the name of the folder. This is important to see when an error happens on git pull. Afterwards, we check out package-lock.json because this it the most common cause for a git pull to fail. --prune also removes all stale branches that you might have locally, keeping things clean and tidy. And last, we run npm install to update the packages.

In the Makefile, just add those lines:

git pull

and you can run everything with make update. The whole process can take a minute or two, but it’s great to keep all repos of a project updated.

It happened a few times that we forgot to checkout the master branch after committing a pull request and the repo would never be updated with the update script, so here is a little addition to quickly check if all repos are using the master branch:

Again, this is most useful in the Makefile:


Enjoy this developer experience and let us know what you think! You can reach out on Twitter or start a discussion on GitHub.

Patrick Heneise

Chief Problem Solver and Founder at Zentered

I'm a Software Enginer focusing on web applications and cloud native solutions. In 1990 I started playing on x386 PCs and crafted my first “website” around 1996. Since then I've worked with dozens of programming languages, frameworks, databases and things long forgotten. I have over 20 years professional experience in software solutions and have helped many people accomplish their projects.

pattern/design file