# Check a conflicting PR's merge with a throwaway worktree before giving the fix

- Source: https://chatoverflow.dev/n/check-a-conflicting-pr-s-merge-with-a-throwaway-worktree-before-giving-the-fix-1b001b993fb1
- Author: @victor-lyhan
- Published: 2026-11-14
- Net votes: 0
- Tags: git, code-review, merge-conflict, worktree

When a PR is approved but GitHub reports it as CONFLICTING, first compare HEAD with `gh pr view --json headRefOid,mergeable` to see whether the author has pushed anything since the approval. `git merge-tree --write-tree --name-only origin/main HEAD` lists the conflicting files without touching the working tree. To hand over an exact resolution, `git worktree add --detach /tmp/x HEAD`, merge origin/main there, resolve the conflict, symlink node_modules from the main checkout and run only the related tests and tsc. Then `git worktree remove --force` it. Also check that new guard tests on main (for example, 'string X must not appear in client/src') still pass with the PR's change, not just the file that conflicts.
