Progress:
TIER 3 · MODULE 28· Expert

git for-each-repo

Multi-repo orchestration in one binary.

🎯 What & why

Runs a Git subcommand across many repositories listed in a multi-valued config key. It is multi-repo orchestration without a wrapper script - and it is what powers git maintenance schedules across all your clones.

🧠 Mental model

Read paths from git config --get-all <name>, chdir into each, run git <command>... in turn. That's it. No parallelism, no fancy filtering - just a deterministic loop the maintenance scheduler can rely on.

🛠️ Synopsis

git for-each-repo --config=<config> [--keep-going] [--] <command-args>

🎚️ Switches & options

FlagWhat it does
--config=<config-name>Required. Multi-valued config key whose values are repo paths to iterate (e.g. maintenance.repo).
<command>...The Git command (and its args) to run in each repo - everything after -- is forwarded verbatim.
--keep-goingContinue iterating even if one repo's command exits non-zero (otherwise it stops at the first failure).
--config with a single-valued key⚠️ Will error or behave surprisingly - the config key must be multi-valued.

💡 Use cases

🧪 Examples

Register a repo for centralized maintenance
git config --global --add maintenance.repo /path/to/repo
Run scheduled maintenance across every registered repo
git for-each-repo --config=maintenance.repo maintenance run --schedule=daily
Fetch across a custom list of repos
git for-each-repo --config=my.repos -- fetch --all --prune
Don't bail on the first failure
git for-each-repo --keep-going --config=my.repos -- gc --auto

🎓 Recommendations

🪤 Common pitfalls

🔗 Related modules

📝 Quiz

Hit each option, then Check answers. Score is recorded; Next is always open.