Managing Stacked Pull Requests

Rebase dependent pull requests onto updated bases using cherry-pick and force-with-lease.

Updated Aug 10, 2021
One-click install
npx skills add https://github.com/johnnymo87/dotfiles --skill managing-stacked-pull-requests
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: Managing Stacked Pull Requests
Source: https://github.com/johnnymo87/dotfiles/tree/main/.claude/skills/managing-stacked-prs
Command: npx skills add https://github.com/johnnymo87/dotfiles --skill managing-stacked-pull-requests

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

When working with PR trains (pr1 → pr2 based on pr1, etc.), you need to update the dependent PRs after merging the base PR. This skill shows how to rebase dependent PRs onto the updated base branch using a cherry-pick workflow.

Core Features & Use Cases

  • Identify commits unique to a dependent PR
  • Cherry-pick those commits onto the updated base branch
  • Update the remote branch with force-with-lease
  • Repeat for entire PR stack
  • Handle both main and master base branches

Quick Start

  • Step 1: Update pr2
    • git fetch origin
    • git checkout origin/pr2
    • git log --oneline
    • git checkout origin/main
    • git cherry-pick <commit-hash1> <commit-hash2> ...
    • git push origin HEAD:pr2 --force-with-lease
  • Step 2: Update pr3
    • git checkout origin/pr3
    • git log --oneline
    • git checkout origin/pr2
    • git cherry-pick <commit-hash1> <commit-hash2> ...
    • git push origin HEAD:pr3 --force-with-lease

Frequently Asked Questions about Managing Stacked Pull Requests

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I update dependent pull requests after merging a base PR?

After merging the base PR, update dependent PRs by checking out each downstream branch, identifying commits unique to that PR using git log, cherry-picking those commits onto the updated base branch, then force-pushing with --force-with-lease to the remote.

What's the best way to rebase a PR stack without losing commits?

Cherry-pick the commits unique to each dependent PR onto the updated base branch rather than traditional rebase. This preserves commit history, works reliably with PR trains, and allows force-pushing with --force-with-lease to safely update remote branches.

Can I automate updating multiple dependent PRs in a PR train?

Yes, iterate through your PR stack using Bash commands to fetch, cherry-pick unique commits from each dependent PR onto its updated base, and force-push with --force-with-lease. The process repeats for each PR in the chain until all are current.

Why use cherry-pick over traditional rebase for stacked pull requests?

Cherry-pick identifies and applies only the commits unique to each dependent PR, avoiding complex rebase conflicts in PR trains. Force-pushing with --force-with-lease protects against accidental overwrites while updating remote branches safely.

Does this workflow handle both main and master base branches?

Yes, the cherry-pick workflow supports both main and master base branches. Specify your base branch when checking out and the process adapts to either naming convention in your repository.