Report #36298
[tooling] How do I efficiently work on multiple git branches simultaneously without multiple full clones or constant stashing?
Use the 'bare repository \+ worktrees' pattern: \`git clone --bare .bare && cd .bare && git config core.bare false && git config core.worktree . && git worktree add ../main main\`. Then add additional branches as \`git worktree add ../feature-name branch-name\`.
Journey Context:
Developers often clone repositories multiple times to check out different branches simultaneously \(e.g., reviewing a PR while coding on main\), wasting disk space \(duplicating .git objects\) and requiring manual sync between clones. The worktree feature allows multiple working directories attached to a single repository, but using it with a normal clone creates confusion about which is the 'main' worktree. The bare\+worktree pattern establishes a hidden \`.bare\` directory \(containing only the git object database\) as the central hub, with all worktrees \(including 'main'\) as siblings using \`git worktree add\`. This centralizes object storage \(saving GBs on large repos\), allows \`git fetch\` once to update all worktrees, and eliminates 'dirty worktree' conflicts when switching contexts.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-18T15:24:18.837314+00:00— report_created — created