gitops

module
v1.2.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 9, 2026 License: MIT

README

gitops

Run a git operation across every repository in a directory at once — from an interactive TUI or a scriptable CLI.

CI Release Go version

Working across a dozen microservice repos means running the same git pull / status / checkout a dozen times. gitops does it once, in parallel, across all of them — and gitops init clones an entire GitHub organization in a single command so you have them to begin with.

Install

brew install IHaveASegway/tap/gitops
Other ways to install
# Go 1.27+
go install github.com/IHaveASegway/gitops/cmd/gitops@latest

Prebuilt binaries for Linux, macOS and Windows (amd64 / arm64) are on the releases page; the checksums are signed with cosign — see SECURITY.md to verify. Or build from source:

git clone https://github.com/IHaveASegway/gitops.git
cd gitops && make build          # ./gitops

Quick start

cd ~/Documents/GitHub/acme       # a directory holding several git repos
gitops                           # launch the interactive TUI

Prefer to script it? Every operation is also a subcommand:

gitops status                    # branch, ahead/behind and changes, per repo
gitops pull                      # fast-forward each repo's default branch
gitops branch -n feature/login   # create the same branch across repos

Starting on a fresh machine? Clone a whole org first, then work in it:

cd ~/Documents/GitHub
gitops init github.com/acme      # → ./acme/<repo> for every repo you can see
cd acme && gitops

The interactive TUI

Run gitops with no arguments inside a directory of repositories. Pick an operation, choose which repos it runs on, confirm anything destructive, and watch it run live. The header always shows where you are and how many repos are dirty, ahead or behind.

gitops operation menu

View Keys
Menu ↑/↓ move · enter select · r rescan · q quit
Repo picker space toggle · a all · n none · i invert · / filter · enter continue
Confirm (reset · push · init) y confirm · esc back
Running esc cancel (kills in-flight git) · ctrl+c quit
Results ↑/↓ move · enter expand · f failures only · esc menu

The CLI

The same operations, headless — for scripts, CI, and one-liners. Output is plain and colorless when piped, so it composes cleanly.

gitops status output across five repositories

Command What it does
pull Check out the default branch and fast-forward it
sync Stash changes, pull the default branch, restore the stash
status Branch, ahead/behind counts and changed files
branch -n <name> Create a branch from an up-to-date default branch
checkout -n <ref> Check out an existing branch, tag or ref
push -m <msg> Stage all changes, commit, and push the current branch
reset Destructive — discard all changes, force to default, pull
init <org> Clone every repo of a GitHub org or user into a subdirectory

Common flags: -d/--dir (target directory), -r/--repos a,b,c (a subset), -j/--jobs (parallelism), -y/--yes (skip confirmation), --skip-submodules (don't update submodules on pull/sync/reset/branch/checkout). Flags may come before or after arguments.

gitops pull -r crm,admin,pay                 # only these repos
gitops push -y -m "fix: bump deps"           # commit + push everything (‑y in scripts)
gitops sync -d ~/Documents/GitHub/other-org  # operate on another directory
Cloning an organization — gitops init
gitops init https://github.com/acme       # → ~/Documents/GitHub/acme/<repo>
gitops init acme --dry-run                 # show the plan, clone nothing
gitops init acme -r crm,admin              # only these repos
gitops init acme --archived --no-forks     # include archived, skip forks
gitops init acme --protocol ssh            # clone over SSH
gitops init acme --prune                   # also remove repos deleted on GitHub

Accepts https://github.com/acme, github.com/acme, acme, git@github.com:acme/repo.git, and GitHub Enterprise hosts. Re-running is safe — it clones only the repos you're missing. Before cloning, init looks at the origin remotes around the target directory and, if the org already exists somewhere else (a differently-named folder, loose clones, or the directory you're standing in), it warns and suggests the --here command that tops up the existing checkout instead of duplicating it.

Keeping a checkout in sync. Re-running init is how you pick up repositories added to the org since you cloned it. It also reports checkouts you still have that the org listing no longer mentions — but it never removes one on that basis alone, because absence from the listing is equally what a rename, a transfer, an archived repo under the default filters, or a token that quietly lost visibility looks like. Each one is looked up by name first, and only a 404 counts as deleted:

  ⚠ 2 repos here no longer on GitHub:
  ~ legacy-etl        gone (404) · clean, nothing unpushed
  ~ spike-branchwork  gone (404) · 2 uncommitted changes, 1 unpushed commit

    These were NOT removed. To remove the clean ones:
    gitops init <org> --prune

--prune removes only the ones confirmed deleted and holding nothing that exists solely on your machine. Uncommitted changes, stashes, commits absent from every remote, or a second remote all keep a checkout — it is reported instead, for you to deal with by hand. Renamed, still-visible and unverifiable repos are always kept. --prune cannot be combined with --repos, since a partial listing can't tell you what is gone.

Authentication: GH_TOKEN, GITHUB_TOKEN, or gh auth login (github.com); GH_ENTERPRISE_TOKEN or gh auth login --hostname <host> for Enterprise. Without a token, only public repositories are listed. Tokens are scoped to their host and passed to git through a process-scoped config override — never written to .git/config or a command line.

init flag Description
-d, --dir Base directory; the <org> folder is created inside it
--here Clone into --dir itself (no <org> subdirectory)
-r, --repos Only clone these repos
--protocol ssh or https
--archived / --no-forks Include archived / skip forked repositories
--dry-run Print the plan and exit
-y, --yes Skip the confirmation prompt
--force Clone even if an existing checkout was detected
--prune Remove checkouts whose repo is confirmed deleted on GitHub

Safety

gitops can touch dozens of repositories at once, so the sharp edges are guarded:

  • reset and push confirm before running in a terminal, and refuse (exit 2) without one unless you pass --yes — an unattended gitops reset can't silently wipe every repo.
  • push never commits .DS_Store or other OS junk.
  • Tokens are host-scoped and never leak to another host; release binaries ship with cosign-signed checksums. Details in SECURITY.md.
  • pull, sync and reset leave each repo on its default branch (they don't return you to where you were); branch leaves you on the new branch.

Exit codes: 0 all succeeded · 1 at least one repo failed · 2 refused (needs --yes, or init found a duplicate) · 130 interrupted.

How it works

  • Discovers git repositories one level below the target directory (worktrees and submodules included).
  • pull, sync, reset, branch and checkout run git submodule update --init --recursive afterward when a repo has submodules; pass --skip-submodules to leave them alone.
  • Detects each repo's default branch via origin/HEAD, then main/master.
  • Runs with a bounded worker pool (--jobs); Ctrl-C kills in-flight git, never orphans it.
  • git never prompts for credentials (GIT_TERMINAL_PROMPT=0), so a repo you can't reach fails fast instead of hanging the batch.
  • Built with Bubble Tea · Lip Gloss · urfave/cli.

Contributing

See CONTRIBUTING.md for the development workflow, testing approach and release process. Changes are tracked in CHANGELOG.md; security reports go through SECURITY.md.

License

MIT.

Directories

Path Synopsis
cmd
gitops command
Command gitops runs git operations across many repositories at once and clones whole GitHub organizations.
Command gitops runs git operations across many repositories at once and clones whole GitHub organizations.
internal
buildinfo
Package buildinfo reports the version of the running binary.
Package buildinfo reports the version of the running binary.
cli
Package cli wires the command line: subcommands for each git operation, the init command, and the interactive TUI when no subcommand is given.
Package cli wires the command line: subcommands for each git operation, the init command, and the interactive TUI when no subcommand is given.
clone
Package clone plans and performs cloning a whole GitHub organization, detecting checkouts that already exist so an org is never duplicated by accident.
Package clone plans and performs cloning a whole GitHub organization, detecting checkouts that already exist so an org is never duplicated by accident.
format
Package format holds small text helpers shared by the CLI and the TUI.
Package format holds small text helpers shared by the CLI and the TUI.
git
Package git runs git commands and inspects repositories on disk.
Package git runs git commands and inspects repositories on disk.
github
Package github talks to the GitHub REST API and resolves how an organization was named on the command line.
Package github talks to the GitHub REST API and resolves how an organization was named on the command line.
github/githubtest
Package githubtest provides a fake GitHub API server for tests.
Package githubtest provides a fake GitHub API server for tests.
ops
Package ops implements the git operations gitops runs across repositories.
Package ops implements the git operations gitops runs across repositories.
report
Package report prints results for the non-interactive CLI.
Package report prints results for the non-interactive CLI.
runner
Package runner executes an operation against many targets in parallel, preserving order and reporting progress as it goes.
Package runner executes an operation against many targets in parallel, preserving order and reporting progress as it goes.
testutil
Package testutil creates real git repositories for tests.
Package testutil creates real git repositories for tests.
tui
Package tui implements the interactive terminal UI: a menu of operations, a repository picker, confirmation for destructive actions, live progress while operations run, and a browsable results view.
Package tui implements the interactive terminal UI: a menu of operations, a repository picker, confirmation for destructive actions, live progress while operations run, and a browsable results view.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL