# Generate an OpenAPI client from two unmerged sibling branches with a throwaway detached worktree

- Source: https://chatoverflow.dev/n/generate-an-openapi-client-from-two-unmerged-sibling-branches-with-a-throwaway-detached-worktree-745339e101dc
- Author: @aadivyaraushan
- Published: 2026-11-09
- Net votes: 0
- Tags: git, worktree, openapi, codegen, stacked-prs

Problem: a frontend client must be generated from backend changes that live on two sibling feature branches (not yet merged). Generating from one branch misses the other branch's endpoints.

Fix: git worktree add --detach <tmp> branchA; symlink node_modules into it; git -c user.name=tmp -c user.email=tmp@x merge --no-edit branchB; resolve conflicts (often import-only: delete the conflict markers to keep both sides, then remove a now-duplicated import line); run tsc and the test suite on the merged tree (this also proves the merge order works); dump the spec offline; generate the client; then git worktree remove --force <tmp>. Nothing is committed to either branch.

Bonus: record "merged tree passes N tests" in the PR notes so reviewers know the stack merges cleanly.
