Introduction
In the world of software development, managing code changes is crucial to maintaining quality and efficiency. With the introduction of Stacked Pull Requests (PRs) on GitHub, developers now have a powerful tool to handle complex changes more smoothly and agilely. This new feature, currently in public preview, promises to transform how teams approach the code review process.
Why Stacked Pull Requests?
Historically, developers have often had to choose between large PRs, difficult to review, and the tedious management of multiple branches for small changes. With stacked PRs, GitHub offers an elegant solution: breaking down large changes into a series of smaller PRs, each representing a distinct "layer" of the overall modification. This approach maintains clarity and precision in the review process.
Benefits of Stacked PRs
- Parallel Review: Teams can now review multiple stacked PRs in parallel, speeding up the approval process. According to a GitHub study, parallel reviews can reduce cycle time by 30%.
- Maintained Quality at Each Layer: By focusing reviews on specific changes, developers can better apply existing branch protections and ensure maximum integrity.
- Simultaneous or Progressive Merging: With the ability to merge an entire set of stacked PRs with a single click, or progressively, teams gain flexibility in managing deployments.
Getting Started with Stacked PRs
Installation and Setup
To leverage stacked PRs, developers can install the GitHub CLI extension using the following command:
``bash gh extension install github/gh-stack ``
Once installed, creating your first stack is quick: start with a branch and a PR for your first change, then add further branches and PRs on top, each PR targeting the layer below.
Practical Use
Stacked PRs can be managed through the terminal, github.com, the GitHub mobile app, or even using a coding agent like GitHub Copilot. This flexibility allows developers to work according to their preferences while benefiting from the innovations offered by stacked PRs.
Testimonials and Use Cases
Tim Neutkens, lead of Next.js at Vercel, stated that using stacked PRs has facilitated introducing smaller individual changes while shipping larger features. This has simplified the PR review process, reducing time-to-market.
John Resig, creator of jQuery, also praised this feature, noting that it removes a lot of friction in developers' daily workflow.
Conclusion
Stacked PRs represent a significant advancement for development teams aiming to improve their management of code changes. By offering more granular review, maintained quality, and simplified merging, this GitHub feature is set to become a must-have.
Let's discuss your project in 15 minutes.