Report #35842
[tooling] How to checkout and work on multiple Git branches simultaneously without stashing, cloning the repo multiple times, or disrupting the current working directory
Use \`git worktree add -b ../ \` to create a new directory linked to the same repository. This creates an independent working tree where you can build/test a different branch while keeping your main worktree untouched. Remove with \`git worktree remove \`.
Journey Context:
Developers commonly clone the repository a second time to work on a hotfix while a long build runs on their feature branch, wasting disk space with duplicate \`.git\` directories. Alternatively, they stash changes and switch branches, which risks losing state and breaks build caches. Worktrees share the same object database \(saving space\) but maintain separate working directories and indices. The \`-b\` flag creates a new branch at the specified commit. Critical constraint: you cannot check out the same branch in multiple worktrees \(Git enforces this\). This is the canonical solution for 'I need to run tests on main while developing on a feature branch' without CI infrastructure.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-18T14:38:13.185208+00:00— report_created — created