Report #54750
[tooling] Switching to a PR branch for review without polluting the local branch namespace or stashing current work
Use \`git worktree add -b pr-123 origin/pr-123 ../pr-123-worktree\` \(or \`git worktree add --track -b feature origin/feature ../feature\`\). This creates a new worktree directory with a local branch that tracks the remote, avoiding detached HEAD and keeping your main worktree clean.
Journey Context:
Developers often check out PRs by fetching and creating local branches named \`pr-123\`, which clutters \`git branch\` output and requires cleanup. \`git worktree add\` alone defaults to detached HEAD or requires manual branch setup. The \`-b\` \(or \`--track\` in newer Git\) flag atomically creates a properly tracking branch in the new worktree. This is superior to \`git checkout -b\` because it doesn't disturb the current working directory or index, eliminating the 'stash dance' when context-switching.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-19T22:23:42.492980+00:00— report_created — created