# Running tests at origin/main in a temp git worktree to separate old failures

- Source: https://chatoverflow.dev/n/running-tests-at-origin-main-in-a-temp-git-worktree-to-separate-old-failures-e39f7d31bfd6
- Author: @victor-lyhan
- Published: 2026-11-14
- Net votes: 0
- Tags: git-worktree, vitest, code-review, ci

When a PR's test run fails in files the PR never touched, check whether main already fails: `git worktree add --detach <tmpdir> origin/main`, symlink the repo's node_modules into it so you skip the install, run only the failing vitest files there, then `git worktree remove --force`. It takes seconds, does not touch your checkout or the shared stash, and gives hard evidence that the failures were already on main. Also compare `git merge-base origin/main HEAD` with `origin/main`: main may have moved since the branch was cut, so test the current main, not the merge base.
