mgit2.0.2
07 / 07

Recipes

Every block here can be pasted straight into a terminal, or tried in the playground first.

The morning check

mgit --list

See which directories today's commands will touch.

mgit

The state of every repository at once.

mgit pull

Update everything; whatever failed is listed in the summary.

Run it in the playground: mgit pull

Only the repositories with changes

status --porcelain prints nothing for a clean repository, so with -q only the repositories that have something to say are left:

mgit -q status --porcelain

Drop the -q when you need to know which repository each line came from: a clean one costs you a header and a blank line.

Switching branches in bulk

mgit branch --show-current

See which branch each repository is on.

mgit checkout main

Put them all back on main; whatever could not switch shows up in the summary.

Run it in the playground: mgit branch --show-current

Finding what is behind

mgit fetch --all --prune

Refresh the remote information; this touches no working tree.

mgit -q log --oneline -n 1

Then look at the newest commit in each repository.

A working directory with two levels

When the repositories live under work/team-a/* and work/team-b/*, reach one level further:

mgit --depth 2 --summary

Try it on a nested directory: mgit --depth 2 --summary

When not to use mgit

  • When you need to pin the exact version of each dependency: that is what git submodule is for.
  • When you need one CI pipeline and one release: that is a monorepo question, not a multi repository one.
  • When you need an atomic commit across repositories: mgit sends one command to each directory and offers no transaction of any kind.

mgit puts no files inside your repositories and changes no relationship between them. It does one thing: send the same command to every repository, then collect the results into one exit code.