Updating Stacked Pull Requests with Git rebase –onto
This article explains how to use `git rebase --onto` to efficiently update stacked pull requests in Git workflows. It covers the problem of keeping dependent branches in sync after changes to a base branch, and provides a practical walkthrough for rebasing a chain of pull requests without breaking history.
Background
Many software teams use *stacked pull requests* — a chain of small, dependent PRs reviewed one at a time. When the base PR changes (e.g., after review feedback), each downstream PR must be updated. `git rebase --onto` is a Git command that lets you replay a series of commits onto a new base commit, dropping the old base. This technique is essential for efficiently maintaining stacked PRs without manually re-creating branches. The article walks through a concrete example of rebasing a stack when the middle PR gets modified.