Learning center

How to keep two offline review versions open at once

Create a detached worktree for each exact version you need to inspect. Git can share its object database across both directories while keeping their working files and indexes separate.

Keep the first review readable during a correction#

Suppose an engineer reviewing a validation patch has local notes and a running test in one checkout. A corrected branch arrives before that review ends. Switching branches in the same directory changes the files the test and editor see. A second worktree lets the engineer inspect the corrected branch without moving the first review’s checkout.

With both versions already in the approved repository, add the detached worktrees:

git worktree add --detach ../inspection-v1 <first-reviewed-commit>
git worktree add --detach ../inspection-v2 <corrected-commit>
git -C ../inspection-v1 rev-parse HEAD
git -C ../inspection-v2 rev-parse HEAD

Record the two printed IDs with the test outputs. Use separate build directories or ports if the test runner otherwise shares state. A worktree changes the working directory Git manages. It does not separate test databases, system caches or network access. Git worktree details

If you also need to decide which commits to inspect again, compare the two patch series before spending time rerunning the first review.

One month of free code review.

New organizations get one calendar month of hosted code review for private and public GitHub repositories. No card or cloud connection required. Eligibility and fair-use terms.

Start free with GitHub

Related reading