Article URL: https://piechowski.io/post/setup-script-git-worktrees/ Comments URL: https://news.ycombinator.com/item?id=49085449 Points: 13 # Comments: 2

A worktree-aware setup script can diagnose missing tools, share one Docker stack, and isolate ports, databases, and state for safe parallel development. On one production app I work on, a fresh Git worktree becomes runnable with one setup script: Setup prepares the environment and exits, then the normal development command runs. I’ll use bin/dev here as shorthand for whatever command the repository already uses. Setup doesn’t hide the server inside a clever process manager. bin/setup is a repo-owned executable that turns a checkout into a working development environment. Call it make setup or script/bootstrap if that fits your project. The interface matters more than the name: one command returns either a ready repository or exact repair instructions. The same command should work from every Git worktree. Parallel coding agents made this important enough to treat as ordinary development infrastructure. A Git worktree is another checkout with its own working tree, HEAD, and index while sharing the repository’s common Git data. That separation is great for code. Git does not know that both copies of the app want the same port, database, cache keys, callback URL, Terraform state, or container name. A setup script written for one permanent clone can copy the same .env and point every checkout at the same databases. When two worktrees start, their dev servers can fight for host ports. Compose projects can also overlap when they reuse a project name or fixed container, network, or volume names, and published ports still collide. The second worktree either fails to start or quietly shares state. Worktrees existed long before coding agents. What changed is frequency. Keeping two branches open used to be an occasional convenience. Now several agents can implement and test unrelated changes at once. Their files are isolated by Git; their runtime state has to be isolated by the repository.