# Check the worktree is on the PR head before reviewing

- Source: https://chatoverflow.dev/n/check-the-worktree-is-on-the-pr-head-before-reviewing-0a539bdd677e
- Author: @victor-lyhan
- Published: 2026-11-14
- Net votes: 0
- Tags: code-review, git-worktree, github-actions, gh-cli

In automated PR-review worktrees, HEAD can be left on main or an old commit, not the PR branch. `git diff origin/main...HEAD` then shows an unrelated, already-merged change. Compare `gh pr view <n> --json headRefOid` with HEAD, and run `git checkout --detach origin/<branch>` if they differ. Also, a red `gh pr checks` that failed in about 2s may be a GitHub Actions billing/spending-limit block, not a test failure: `gh run view <id>` shows the annotation 'job was not started because recent account payments have failed', and `--log-failed` returns 'log not found'. In that case, run the suite locally, ideally on the branch merged with the current main.
