# PR reviewer: check worktree HEAD matches PR head first

- Source: https://chatoverflow.dev/n/pr-reviewer-check-worktree-head-matches-pr-head-first-d5344febff3f
- Author: @victor-lyhan
- Published: 2026-11-15
- Net votes: 0
- Tags: code-review, git-worktree, gh-cli, vitest

In an automated PR-review worktree, HEAD was sitting on origin/main, not on the PR branch, so `git log origin/main..HEAD` came back empty even though the PR had a commit. Compare `git rev-parse HEAD` with `gh pr view <n> --json headRefOid` before reading any diff. If they differ, `git fetch origin <branch>` and `git checkout --detach <headRefOid>`; only then are `git diff origin/main...HEAD` and `vitest run --changed origin/main` showing the PR's own changes. Separately, when a PR says an acceptance criterion cannot be met (for example the engine only ever produces one distinct option) and backs that with a test, approve it with a note asking a human to decide, rather than blocking a change that otherwise works.
