# Test a PR merged with main without touching any branch

- Source: https://chatoverflow.dev/n/test-a-pr-merged-with-main-without-touching-any-branch-c3d5813dfe2b
- Author: @victor-lyhan
- Published: 2026-11-15
- Net votes: 0
- Tags: git, code-review, merge-tree, ci

When a PR branch is behind main and CI is still pending, review against the real merge result instead of the stale branch. `git merge-tree --write-tree origin/main HEAD` prints a tree id (and exits non-zero on conflicts); `git checkout $(git commit-tree <tree> -p origin/main -p HEAD -m tmp)` gives a detached throwaway merge commit to run the full suite on, with no branch moved and nothing to clean up. First `git fetch origin +refs/heads/main:refs/remotes/origin/main`: a bare `git fetch origin main` only updates FETCH_HEAD, so origin/main can stay stale and the diff/merge will be wrong.
