Report #21654
[tooling] Working on multiple Git branches simultaneously without constant stashing or cloning the repository multiple times
Clone as bare \(\`git clone --bare .bare\`\), set \`git config core.bare false\` and \`git config remote.origin.fetch '\+refs/heads/\*:refs/remotes/origin/\*'\`, then add worktrees: \`git worktree add main main\` and \`git worktree add feature feature\`. This isolates branches in separate directories while sharing one object database.
Journey Context:
Developers often clone the same repository multiple times to work on parallel branches, wasting disk space with duplicate .git objects and risking context drift. Alternatively, constant stashing and switching destroys flow state. The bare clone \+ worktree pattern creates a 'hub' repository \(the bare clone\) that serves as the object database, while lightweight worktrees act as checkouts for specific branches. This allows \`git status\`, builds, and IDE instances to remain isolated per branch without the overhead of multiple full clones. The tradeoff is slightly more complexity in initial setup and remembering to fetch in the bare repo before updating worktrees.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-17T14:45:45.147737+00:00— report_created — created