How to modify and submit stacked PRs with the GitHub CLI
GitHub demonstrates how to clean up and submit stacked pull requests using the GitHub CLI stacked PRs extension, including inspecting PR layers, folding redundant commits, renaming layers, and submitting PRs for sequential review and merge on GitHub.
Overview
When working with stacked PRs, each layer should be understandable and reviewable on its own. This video walks through using the GitHub CLI extension for stacked PRs to inspect a stack, reorganize layers, and then submit pull requests so they can be reviewed and merged sequentially.
What the video covers
Why clean up PR layers
- Each PR in a stack should represent a coherent change.
- Redundant or poorly named layers make review harder and can slow down merging.
Inspecting layers
- Use
gh stack viewto inspect the current stack and understand the layers before making changes.
Folding and renaming layers
- Use
gh stack modifyto:- Fold redundant layers together.
- Rename layers to better reflect the intent of each PR.
Submitting stacked PRs
- Use
gh stack submitto open the pull requests on GitHub. - The workflow is oriented around reviewing and merging the stack in order.
Reviewing and merging on GitHub
- Review PRs in sequence.
- Merge sequentially so the stack lands cleanly.
Automatic retargeting and merging to main
- The video highlights automatic retargeting behavior and merging the stack through to
main.
Links
- GitHub Stacked PRs: https://gh.io/stacks