As a developer you operate on many repositories. To keep all of the repositories up-to-date there are as many strategies as there are developers. Personally I have gone from doing it manually, to writing scripts (e.g. 1, 2), trying different tools (e.g. 1), and the latter is what this post is about.
myrepos is a command-line tool which
mr command to your environment.
mr does not care about
different version control systems, it supports all of them.
The standard way to use
mr is to go into each one of your repositories
and run the command
mr register for
mr to add it to your
configuration file in
This is a bit tedious, though it can easily be automated. After all the
repositories have been registered with
mr, then it can pull off its
party tricks. 🎉
The first trick is to clone all the repos into a nice hierarchy, with a
The next trick is to update all of the repos:
mr update. This is just
the start, however, first you must install the
mr is a Perl script, and it is available anywhere Perl runs. To name
a few ways to install it:
git clone git://myrepos.branchable.com/ myrepos
apt install myrepos
pacman -Sy myrepos
apk add myrepos
nix-env -i mr
pkg install myrepos
brew install mr
If a command, for example
mr update, is run in e.g.
mr only runs it on that
If it is run in the parent, e.g.
~/dev/dhis2/apps, then it only runs the
update command in all children
of that directory. In this case, it would run
update in all the app
If the command is run on a higher level, e.g. in
~/dev/dhis2 then the
command applies to all registered repositories in
Through this hierarchical structure, it is possible to manage all of your repositories using a single configuration file, both personal and work related, simply by running your commands in the relevant directory.
The primary commands you will want to use are:
mr checkoutclones any repositories which don't already exist
mr updateupdates all the repositories
mr cleanprints the ignored/untracked files in repos, use
-fto remove files as well
mr statusshows you the status of each repo; handy to figure out if any repos have pending changes
mr diffshows you the diffs from all repos
mr runallows you to run an arbitrary command in all repos
Check out the manual of
myrepos, it is not long and has some nice
tidbits about parallel execution. Alright, I will give up that last one:
use the switch
mr -j 5 to run 5 concurrent jobs.
This is where the tool starts to shine, not only is this a full-featured repository manager; it also gives you tools to do batch operations across multiple repositories.
Custom commands under the
[DEFAULT] section only apply to the
repositories which are under that section. This is why all the custom
commands are placed at the very top of the
Some examples I use it for are:
To save on space I have a
mr nuke command set up which removes the
node_modules from all repositories:
It is easy to extend this to e.g. run
yarn install in all
repositories. Or, generate bundle reports of all the apps using
I use this to serve a listing of bundle reports for analysis.
It is possible to teach
mr a lot of tricks, some handier than others,
for example figuring out the merge-base for different branches:
Which can be used as:
mr octo master v32 and it will give you the
origin/v32 and check it out for
This simplifies backporting bugfixes a bit.
mr unlink: Remove any symlinks (created through e.g.
yarn link) between packages
mr link <package>: Create a symlink to a specific package and link it to all packages that depend on it.
mr boil: Setup all the standards for code, repos, packages, continuous integration on a new branch, commit the changes, and push the new branch to origin in a new PR.
At some point it might make sense to integrate this type of
d2, but for now,
mr is a very handy tool for
developers who have to deal with multiple repositories.
This is my full configuration at the time of writing. You can use it to get started, or set up your own from scratch with only the repos and target directories you need.
Do you have any useful ideas for a command? Please comment on the Gist. 😘