Review someone's stack
A teammate opened PR #142, and PR #142 is the top of a stack. You want to read the whole thing locally, bottom-up, with the parent edges intact.
What you'd otherwise do
Without sm, you'd manually walk the PR chain — find each PR's base ref, check it out, repeat:
gh pr view 142 --json baseRefName # find the parent PR
gh pr checkout <parent-branch-name>
gh pr view <parent-pr-number> --json baseRefName
gh pr checkout <grandparent-branch-name>
# ...repeat down to trunkTedious, and you don't end up with parent metadata recorded — sm log won't render the tree.
With sm
sm get 142What this does, in order:
gh pr view 142 --json baseRefName,headRefNameto find the chain.- Walks the
base_refchain down to trunk. gh pr checkouton each branch.- Records parent metadata (
branch.<n>.stac-man-parent,-parent-sha). - Records the PR number on each branch (
branch.<n>.stac-man-pr). - Leaves HEAD on the top branch.
- Prints
sm log.
Starting from PR #142, ending state
stac-man
main
└─ feat/db-schema #140 merged
└─ feat/api-endpoints #141 open CI ready
└─ feat/web-form ← current #142 open CI conflictfeat/web-form is the PR you want to review (HEAD is on it). CI conflict flags it as CONFLICTING on GitHub — typical when an ancestor has merged but the local chain hasn't been rebased onto trunk yet. Run sm sync to clean that up before reading the diff.
Now you can walk the chain bottom-up. Jump to the branch sitting directly on trunk (feat/db-schema):
sm bottomStep up one branch (feat/api-endpoints):
sm upAnd once more (feat/web-form):
sm upOr jump directly:
sm checkout feat/api-endpointsEach branch is real — you can run tests, set breakpoints, even commit fixups.
Reading the stack diff
sm show on each branch tells you the commits unique to that PR:
sm checkout feat/api-endpoints
sm showIf you want a single diff scoped to one layer (no parent commits):
git log --reverse --patch feat/db-schema..feat/api-endpointsWhat sm get does NOT do
- It does not pull unsubmitted descendants. If the author has more branches stacked on top of
feat/web-formlocally that haven't been pushed, you won't see them. - It does not run
sm restack. Branches are checked out exactly as they exist on origin, even if origin's chain is "wrong" relative to current trunk.
Cleanup after review
When you're done reviewing, you can drop the stack from your local repo:
sm checkout main
git branch -D feat/web-form feat/api-endpoints feat/db-schemaOr use sm untrack --reparent if you want to keep the branches but drop them from sm's graph.
See also
sm get— flag reference.sm submit— the inverse: push your own stack as PRs.- Concepts → Parent metadata.
