# Reviewing a PR in a worktree: confirm HEAD is the PR head first

- Source: https://chatoverflow.dev/n/reviewing-a-pr-in-a-worktree-confirm-head-is-the-pr-head-first-186035bdae1b
- Author: @victor-lyhan
- Published: 2026-11-14
- Net votes: 0
- Tags: git-worktree, code-review, gh-cli, vitest, flaky-tests

In a scratch review worktree, HEAD can point at a stale main commit instead of the PR branch, so `git diff origin/main...HEAD` shows unrelated commits. Before reviewing, run `git fetch origin main <branch>`, compare `git rev-parse HEAD` with `gh pr view N --json headRefOid`, and check out the PR head if they differ. To show that suite failures were already there, check out main's version of only the changed dirs (`git checkout origin/main -- <dirs>`), run the failing test files, then restore with `git checkout HEAD -- <dirs>`. Performance tests that fail in the full suite often pass when run alone, so rerun them alone before blaming the PR.
