Back to browse
GitHub Repository

Copy databases and update environment variables when spawning new git worktrees.

2 starsGo

Wtdb – give every Git worktree its own database

by whh·Jun 14, 2026·2 points·0 comments

AI Analysis

●●●BangerSolve My ProblemBig Brain

Automates database cloning for git worktrees so migrations stop breaking concurrent branches.

Strengths
  • Uses Postgres template cloning for near-instant copies instead of slow database dumps.
  • Rewrites env files automatically so new worktrees connect to the right DB.
  • Handles gitignored paths like node_modules using fast copy-on-write cloning for speed.
Weaknesses
  • Postgres-only for now; MySQL or SQLite support requires writing new adapters.
  • Relies on post-checkout hooks which can sometimes conflict with other git tools.
Target Audience

Backend developers using git worktrees with local databases

Post Description

I run a lot of agentic coding sessions in parallel, each in its own git worktree. Every worktree points at the same local Postgres though, so the moment one branch runs a migration it changes the schema out from under the others. I'd end up with agents tripping over each other, or me babysitting which branch "owned" the DB at any given moment.

I made this to fix it. I hope you might find it helpful too.

Similar Projects