* Welcome to my corner of the web! *

monopoly-repo

Move code between git repositories with full history — keeping git log, git blame, and git bisect intact


A CLI tool for relocating code across git repositories without losing its history. Move a directory, package, or individual file between a monorepo and a dedicated repo — in either direction — and git log, git blame, and git bisect keep working exactly as before.

Quick Start

Requires git 2.22+ and Python 3 — no install needed, just run it with npx.

# Every command has the same shape: move a <source> path into a target
# repo, optionally rename it with --as, and preview first with --dry-run.
npx monopoly-repo move <source> --to <repo> [--as <path>] [--dry-run]

# Move a package out of a monorepo into its own dedicated repo
npx monopoly-repo move packages/auth --to ../auth-service --as auth

# Pull a standalone repo back into a monorepo
npx monopoly-repo move auth --to ../my-monorepo --as packages/auth

# Move a single file to a shared repo
npx monopoly-repo move src/logger.ts --to ../shared

# Preview any move first — nothing is committed, pushed, or deleted
npx monopoly-repo move packages/auth --to ../auth-service --dry-run

# Prefer a shorter command? Install globally and drop the npx
npm install -g monopoly-repo
monopoly move packages/auth --to ../auth-service --as auth

Features

  • History-preserving moves — Relocate code while keeping the full commit history and authorship attribution intact.
  • Bidirectional — Supports round-trips (A → B → C and back to A) so code can move freely between repositories.
  • Safe by default — Never auto-commits, pushes, or deletes source files; you stay in control of every step.
  • Dry-run mode — Preview exactly what a migration will do before running it.
  • Flexible path remapping — Move and re-organize paths in a single operation.

Why it exists

Splitting a monorepo or consolidating scattered repos usually means choosing between a clean move and a usable history. A naive cp + commit throws away years of git blame; manual git filter-repo surgery is error-prone. monopoly-repo makes the history-preserving path the easy one, so moving code is a routine operation rather than a one-way migration.