Manage multiple git repositories with ease.
- 🤓 -> Run any shell or git command on multiple
gitrepositories. - 🤓 -> Re-clone all your repos on new machines.
- 🤓 -> Limit actions to custom tags.
- 🤓 -> Easy to remember and use command list (
add,exec,clone,tagetc.). - 🤓 -> A-GPL v3 licensed labour of love ❤️.
To get an idea what a real use might look like take a look at this blog post: "Using Gitopolis to Manage Multiple Git Repositories"
Or watch the demo video:
- Grab the latest release,
- unzip it
- put the binary somewhere in your
PATH.
I suggest adding a shorter shell alias to save typing. Perhaps gm for git many or gop.
If you're a rust user, you can install from crates.io:
https://crates.io/crates/gitopolis
cargo install gitopolisThis will download the latest release crates.io, build and install it to ~/.cargo/bin/.
A Nix flake wrapping the prebuilt GitHub release binaries lives on the nix branch of this repo. It's auto-updated whenever a release is published.
Run without installing:
nix run github:timabell/gitopolis/nix -- --helpInstall into your profile:
nix profile install github:timabell/gitopolis/nixReference from a NixOS / home-manager flake:
inputs.gitopolis.url = "github:timabell/gitopolis/nix";
# then: gitopolis.packages.${pkgs.system}.defaultSupported systems: x86_64-linux (musl-static, runs on NixOS without patching), x86_64-darwin, aarch64-darwin.
Gitopolis is in the AUR, so you can install it with paru or yay or your AUR helper of choice.
paru -S gitopolisor
yay -S gitopolishttps://repology.org/project/gitopolis/versions
gitopolis has a fully documented command system, so use -h to get help for each command:
gitopolis -h
gitopolis clone -hThere are several ways to get started:
cd ~/repos/
gitopolis add *You can tag repos as you add them (same --tag syntax as clone):
gitopolis add --tag work,backend api-service billing-servicegitopolis clone https://github.com/username/repo1.git# Decide where to put the repos
mkdir ~/repos/
cd ~/repos/
# Grab a config file from somewhere (maybe a colleage) and add to the folder you'll keep the repos in
wget https://gist.githubusercontent.com/timabell/87add070a8a44db4985586efe380757d/raw/08be5b3c38190eeed4fda0060818fa39f3c67ee3/.gitopolis.toml
# Clone all the repos held in the downloaded config file to the current folder
gitopolis cloneTake a look at the python scripts at github.com/timabell/cloner
This script can read repo lists from github and azure devops and write them to a gitopolis config file ready for cloning, including some sensible default tags.
gitopolis exec -- git pull
gitopolis exec -- git statusCommands executed with gitopolis exec and gitopolis clone run in a "non-interactive" (non-TTY) environment to prevent hanging on prompts or pagers.
This means:
- Commands won't prompt for interactive input
- SSH/GPG keys must already be loaded and unlocked in ssh-agent or similar
- Remote SSH host keys must already be accepted (in
~/.ssh/known_hosts) - The easiest way to ensure keys and hosts are all setup and ready if you run into this problem is to run a single git fetch/clone outside gitopolis first. If this proves to be a regular hassle for new users then we could look at doing something about it so add your experience to issue #236.
- Git commands won't pause for pagers (like
lessforgit log) - this is intentional, but you can pipe the output of gitopolis as a whole into less - e.g.gitopolis exec -- git log -n 1 | less - Git will default to no-color output, but you can force git's coloured output with
git -c color.ui=always.
If a command is still running after 5 minutes in any one repo (e.g. git hung waiting on a remote or a credential prompt it can't show), exec kills it (and anything it started) and moves on to the next repo. It's reported as a failure in the summary at the end. Change the limit with --timeout <seconds>, or use --timeout 0 to disable it for genuinely long-running commands:
gitopolis exec --timeout 30 -- git fetch
gitopolis exec --timeout 0 -- cargo build --releaseFor compact, parsable output that's easy to sort and analyze use --oneline, this will put all the output on a single line for each repo (removing newlines).
e.g. to see the latest commit for all the repos, with the most recently touched repo first:
gitopolis exec --oneline -- git log --oneline -n 1When dealing with many git repos, it can be cumbersome and slow to have to run commands on every repo every time, so you can use tags to filter down what's relevant to you in the moment, e.g. backend, my-team, rust or any other way of categorizing you can thing of.
gitopolis tag some_tag repo1 repo2
gitopolis exec -t some_tag -- git pullYou can use multiple tags with powerful AND/OR logic to precisely filter repositories:
- Comma-separated tags (within a single
--tagflag) use AND logic: all tags must match - Multiple
--tagflags use OR logic: at least one tag group must match
Examples:
# Match repos with BOTH 'backend' AND 'rust'
gitopolis list --tag backend,rust
# Match repos with (backend AND rust) OR (frontend AND typescript)
gitopolis exec --tag backend,rust --tag frontend,typescript -- git pull
# Clone repos with (production AND critical) OR (staging AND critical)
gitopolis clone --tag production,critical --tag staging,criticalThis allows for flexible repository filtering based on combinations of characteristics.
list, exec, sync and clone (from config) also take --exclude (repo paths) and --exclude-tag (tags), both comma-separated and/or repeated. Exclusions are applied after any --tag filter, and a repo with any of the excluded tags is left out.
# Pull everything except one slow repo and anything tagged archived
gitopolis exec --exclude huge-monorepo --exclude-tag archived -- git pull
# Tag repos you want to "disable" without removing them from gitopolis
gitopolis tag disabled old-thing other-old-thing
gitopolis exec --exclude-tag disabled -- git statusShow the recorded information about a specific repository:
$ gitopolis show 0x5.uk
Tags:
public
github
blog
rust
Remotes:
origin: [email protected]:timabell/0x5.ukList all repositories with tags and remote URLs:
gitopolis list --long # multi-line, human readable
gitopolis list --tab # one line per repo, tab separated: path, tags (comma-separated), remotes (name=url, comma-separated). Good for scripts.List all tags and the repositories they're applied to:
gitopolis tags --longMove a repository to a new location and update the configuration:
gitopolis move repo old-path new-pathThis works like unix mv:
gitopolis move repo my-repo new-name # rename my-repo to new-name
gitopolis move repo my-repo archive/ # move into archive/my-repo (archive/ created if needed)
gitopolis move repo my-repo existing-dir # existing-dir already exists, so becomes existing-dir/my-repoIt refuses to overwrite anything that already exists at the destination.
Gitopolis supports multiple git remotes per repository. Sync remotes from your git repositories into the .gitopolis.toml file:
gitopolis sync --read-remotesSync remotes from .gitopolis.toml back to your git repositories:
gitopolis sync --write-remotesNote there is no automatic sync, gitopolis will never fiddle with the remotes in the managed repos or its own config unless relevant commands are invoked.
Gitopolis supports executing complex shell commands for each repository - including pipes, redirection, and chaining with && and ||.
To use these features, pass your entire command as a single quoted string to avoid the shell you are using processing them before they get to gitopolis:
gitopolis exec -- 'git status && git pull'
gitopolis exec -- 'git log -1 | grep "feat:"'You can combine this with normal shell piping/redirection of the entire gitopolis output, e.g.:
gitopolis exec -- 'git log -1 | grep "feat:"' | wc -lGitopolis creates and manages all its state in a single simple .gitopolis.toml file in the working directory that you can edit, read, share with others and copy to other machines.
It is stored in TOML format which is a well-supported config markup with parsers for many programming languages.
Here's an example of the contents:
[[repos]]
path = "gitopolis"
tags = ["tim"]
[repos.remotes.origin]
name = "origin"
url = "[email protected]:timabell/gitopolis.git"
[[repos]]
path = "schema-explorer"
tags = ["tim", "databases"]
[repos.remotes.origin]
name = "origin"
url = "[email protected]:timabell/schema-explorer.git"
[[repos]]
path = "database-diagram-scm"
tags = ["databases"]
[repos.remotes.origin]
name = "origin"
url = "[email protected]:timabell/database-diagram-scm.git"The TOML array format takes a little getting used to, but other than that it's pretty easy to follow and edit by hand, and it allows clean round-trips of data, and is supported in just about every programming language.
Think a metropolis of git repos.
It's a lot to type as a name, but it's nice and unique, and if you use it a lot I suggest you create a shell alias to something shorter.
- Wanted to learn more Rust.
- Had a client with many microservices and teams.
- Tried gita but found command layout hard to remember, and didn't like having to install python.
- To help others with their microservices.
More recently I've been adding more features to help with other clients, and enjoying the benefits of high-quality end-to-end tests as I increasingly work with claude code on shipping features considerably more rapidly (though not always more easily lol, crazy LLMs).
If you find this useful, or just think it's cool, please do help spread the word.
- Star the repo
- Tell your friends
- Share your gitopolis config with colleagues and use it to help onboard new developers to your team
- Post on social media, youtube, reddit etc about your experiences, (good or bad), and don't forget to tag me!
Suggestions welcome, particularly adding your experience, problems and ideas to the issues list.
I'm happy for people to open issues that are actually just questions and support queries.
Rough internal design and ambitions can be found at Design.md.
PRs are appreciated though it might be best to open an issue first to discuss the design.
Every push to main is built and tested on Linux, macOS and Windows. If there are release-worthy commits since the last tag, a GitHub release is created with binaries, checksums and release notes generated by git-cliff, the crate is published to crates.io, and the flake on the nix branch is updated.
Commits prefixed feat:, fix:, refactor:, perf:, doc:, security: or chore: are release-worthy and appear in the release notes (see cliff.toml). Anything else, e.g. ci: or no prefix, doesn't trigger a release.
Each release bumps the patch version. To bump minor or major, or to force a release when nothing is release-worthy, add a footer to a commit message:
feat: add new feature
bump: minor
bump: major and bump: patch work the same way.
Preview release notes:
./release-notes.sh # latest release
./release-notes.sh --preview # unreleased changesRun ./upgrades.sh to run all of upgrade-rust.sh, upgrade-crates.sh and upgrade-actions.sh (needs gh). Each refuses to run with staged changes and commits its own result. The Rust and crate upgrade commits include a bump: patch footer so they trigger a release; the actions upgrade only affects CI, so it does not.
Here's the other tools I'm aware of that have more-or-less similar capabilities
git for-each-repo- new built-in git command for running git commands on many repos- gita - requires python
- myrepos aka "mr"
- GitKraken - Commercial tool
- https://stackoverflow.com/questions/816619/managing-many-git-repositories - stackoverflow question on the same
- gr
- git-repo
- git slave
- mani a TUI (text user interface)
- RepoZ - a Windows GUI tool