GitHub Stacked PRs
9 hours ago
- #Development Tools
- #GitHub
- #Pull Requests
- Stacked PRs allow arranging pull requests in an ordered stack to merge them all in one click.
- Each PR represents one focused layer of a change, reviewed independently and landed together.
- GitHub provides a UI for navigating between PRs in a stack and checking each layer's status.
- A powerful CLI (`gh stack`) facilitates creating stacks, performing rebases, pushing branches, creating PRs, and navigating layers.
- AI agents can be integrated to teach them how to work with stacks using `npx skills add github/gh-stack`.
- Stacked PRs address issues with large pull requests by breaking big changes into small, focused PRs.
- A stack consists of a chain of PRs where each targets the branch of the PR below it, ultimately landing on the main branch.
- GitHub supports stacks end-to-end with UI features like stack maps, branch protection enforcement, and CI runs.
- The CLI handles local workflow, while GitHub's PR UI provides context for reviewers.
- Merging can be done for all or part of the stack, with automatic rebasing of remaining PRs after a merge.