r/github • • 28d ago

Question Best practices for stacking draft PRs?

Hey guys I’m wondering what type of precautions you take or guidelines you follow when stacking multiple draft PRs?
I understand that each next PR should stack on top off the latest one not main but is there more to it? Like:

What’s the most you ever stacked?
At which point is it too deep?
Any lessons learned about stacking?

Thanks

4 Upvotes

8 comments sorted by

5

u/Torutofu_Raeva 28d ago

2-3 deep is my limit, past that every rebase at the bottom turns into a cascade. also point each pr's base at the previous branch so github retargets the rest when the bottom one merges

4

u/zaufi444 28d ago

`gh stack` CLI (it's a separate installable extension) helps me a lot...

1

u/Geraldwelly 27d ago

3 deep is where it starts hurting for me. Past that, a review comment on the bottom PR turns into a rebase chain that eats the afternoon. Two habits help: rebase the stack with `git rebase --update-refs` so all the branch pointers move together, and keep the bottom PRs boring (types, interfaces, pure refactors) so they merge fast and the stack drains from the bottom. Put "depends on #123" in each description so reviewers don't review the parent's diff twice. And if you're letting coding agents open PRs, stacking is how you keep each one reviewable, but give the agent the stack order explicitly or it'll happily branch everything off main.

1

u/Chicharoh 27d ago

Thanks chatgpt

2

u/maven87 28d ago

Mostly just avoid too many changes in the earlier PRs in your stack, after it's been referenced in a later PR. If you're going to make a significant change, add to the stack instead of fixing it in the existing PR. Otherwise you're going to deal with merge hell across the stack.

2

u/Suspicious_Data_2393 28d ago

i can’t say i have any experience stacking draft PRs. What does stacking PRs mean? You mean feature related PRs? Or not necessarily code related?

2

u/heseov 27d ago

Use gh stack and limit the prs to 3. It's such a pain to fix merge conflicts, even with agents. Especially if you have a lot of reviews processes in a pr, it really adds up with each new commit against a stack.

1

u/_4rcadia 24d ago

The most common use case for me is a prereq refactor followed by a feature/fix. So 2-3 is usually good. At most, I've stacked 5 PRs. It is a series of refactors followed by a few features. Generally, stack only when they are strictly dependent. Do not stack orthogonal features just to merge them at once.