Top
Best
New

Posted by tomzorz 5 hours ago

Stacked PRs are now live on GitHub(github.blog)
304 points | 107 commentspage 3
santoriv 2 hours ago|
The important question in the age of PR metrics as a yardstick for keeping your job:

When you click merge, does a 3 stack PR show up as 1 PR in the Dx metrics or 3?

qihqi 1 hour ago||
inspired by https://github.com/ezyang/ghstack?
Insimwytim 3 hours ago||
I feel like many people (and industry in general) complicate things unnecessary.

  Stacked pull requests break large changes into small, reviewable pull requests. 
That's how pull requests are supposed to be, no? If yours aren't that - you ought to rewrite them.

  With stacks, you can independently review and check each pull request, then merge everything together in one click.
Why would I want to do that instead merging (and deploying/testing) separately, which gives me more reliability?

  No more opening a single large pull request that takes forever to review, or splitting work across multiple branches you have to keep manually rebasing.
Well, it doesn't seem like a simplification over dreaded "manual rebasing". And the target branch still moves, doesn't it? So, how are you "saved" from rebasing?

It's like responsibility is shifted from the author to the tool. That has been tried before, and every time it seem to consistently produce a similarly shaped mess in a different area of a process, but with an added bonus of the tool's own problems and restrictions.

tao_oat 3 hours ago||
Here's a common flow where I find stacked PRs are useful:

- I want to build feature X

- Ah, but it would work better if I refactored the module first

- I refactor then build feature X

- There's then some additional (and optional) cleanup work

As a reviewer I wouldn't want to see all this in a single PR, and the changes depend on each other so I can't open multiple independent PRs. Manual rebasing is fine but navigating the GitHub UI is then annoying, I have to mentally keep track of where I am in the stack.

mchristen 3 hours ago|||
Those could just be individual commits on a branch. Why does it need to be a stacked PR? That concept really only exists within the interfaces of these kinds of tools.
andrewaylett 2 hours ago|||
They don't. But reviewing individual commits in the GitHub UI is hard.

A set of stacked PRs is exactly the same as a line of commits. The only difference is the UI, but the UI is the important bit here because lack of UI is what's stopping folk from doing that today.

Even when I've developed my changes as a stack of commits, I'll feed them to my team one commit (and one PR) at a time so they're easier to review — and I discovered that GitHub had turned on stacked commits UI because for one particular project I'd manually created a set of PRs in advance (with the right bases) and GitHub offered to create a stack out of them.

4lx87 2 hours ago||
> They don't. But reviewing individual commits in the GitHub UI is hard.

So instead of solving that problem, GitHub developed tooling around a workaround for that problem (targeting a PR at another branch that also has a PR).

Expanding reviews to allow per-commit reviews avoids the need for managing additional branches and all the headache that comes with it.

esafak 2 hours ago|||
They could but they don't belong together. A PR should be about one thing. Refactoring one module for another's sake should be done in another PR. If not for reviewing, for revertability, and future debuggability.
kazinator 3 hours ago||||
I certainly don't want to see that in a one commit. A PR has one more more commits, though.

The commits in a PR are already a stack of patches, and so PRs are already "stacked" as they are.

If feature X depends on the refactoring (cannot be rebased on the un-refactored upstream), it's part of the change; you can't just merge the feature and not the refactoring.

If the two are separable that way then, sure, it makes sense to ask for them to be separate PRs.

Insimwytim 3 hours ago|||
I do that too. I do introduce changes in separate PRs. They could be related to the same problem and referenced accordingly.

  and the changes depend on each other so I can't open multiple independent PRs
Why? Is it a technical restriction? Tightly coupled architecture is not the best solution anyway.
malcolmgreaves 3 hours ago||
A refactor and then a feature implemented on that refactor is tightly coupled by definition. It would not make sense to implement the feature and refactor independently, because you’d be wasting time implementing a feature that you would have to refactor again.
pyth0 2 hours ago||
This is literally the point of stacked PRs. You implement the refactor in branch A, then branch B is created on top of that so you can implement your feature. Then you make separate PRs, one for merging branch A into main, and another for merging branch B into A. The GitHub feature just provides a nicer UX when interacting with such PRs by clearly showing dependency and allowing you to merge a stack together.
kazinator 3 hours ago|||
I also don't get it.

> With stacks, you can independently review and check each pull request, then merge everything together in one click.

Consider:

"With pull requests, you can independently review and check each commit inside the pull request, and then merge the entire pull request in one click."

Pull requests are stacked commits. This does not have to recurse; you don't need stacked pull requests, not to mention stacked pull request stacks.

A commit can already contain changes to multiple files. In many cases, even a complex change can be just one commit. A sequence of multiple commits handles all the remaining cases.

Stacked PRs sound like a use case for someone who never wants a PR to be a container for multiple commits, such that if a unit of work is best done as three commits, they want them in separate PRs. Oh, but now they are not related together, the way a stack of commits is related under one PR, so we need a meta-PR to contain PRs or something.

This could be a consequence of commits being sort of second class citizens in the GitHub UI compared to PRs. If you want a commit to be treated as PR, on the same level, you must create a PR with nothing but that commit. So then, what would have been a single PR with four commits that you could merge with one click is now four PRs. Which you want to be able to merge them with one click.

masklinn 2 hours ago||
> With pull requests, you can independently review and check each commit inside the pull request, and then merge the entire pull request in one click

Except you can’t really do that on GitHub, the “unit if review” is the PR so reviewing commits is adhoc, inconsistent, and awkward, and tracking their changes as they get fixed up is a pain. “Splatting” that as PRs is not the nicest way to do it green field, but it’s an evolution that makes sense in GitHub’s model.

kazinator 1 hour ago||
Right; so maybe that's the thing to fix.
mrkeen 2 hours ago||
I don't mind rebasing, so that's not really an issue.

The problem I sometimes have is when I queue up 4 or 5 PRs in the afternoon and expect someone to take a look in the morning.

The diff of A into master looks OK, but then the diff of B looks like AB, and the diff of C looks like ABC - each PR has changes that will have already been merged once earlier PRs have been accepted.

My way around it was to raise E as a PR into D, raise D as a PR into C, etc. Then once approved, I change their destinations back to master for the actual merges.

It really confuses reviewers though, even though it's meant to make it so they only see the appropriate changes.

efromvt 4 hours ago||
Praise be, stacking is such a better ux for separating out a feature diff into distinct component units and native support makes it easy.
smb06 1 hour ago||
As one of my colleagues said - "only took them 5 years"
zxspectrum1982 1 hour ago||
I don't like this.

The case where I need stacked PRs is when I have a ton of changes and I want to upstream them. I have so many changes that I have probably written code in this order: 1. feature1 work 2. feature2 work 3. architecture rework 4. docs 5. feature3 work 6. optimization 7. docs 8. feature4 work 9. security fixes 10. optimization 11. docs 12. last pass security fixes

By the time I want to upstream, I probably want to reorder my commits and generate on PR per theme (arch, feature1 + docs + optimization, feature2+docs + optimization, etc) before I submit a bunch of PRs.

GitHub stacked PRs solve none of my problems. Stacked PRs doesn't take care of the reordering of commits, it doesn't take care of rebasing changes, it adds very little on top of what I was already able to do by saying "this is PR 1 out of 7, this is PR2 out of 7 and build on top of the branch that I used for PR1/7, etc".

Hugely disappointing, bordering useless.

IshKebab 1 hour ago|
> it adds very little on top of what I was already able to do by saying "this is PR 1 out of 7, this is PR2 out of 7 and build on top of the branch that I used for PR1/7, etc".

That's literally all it's supposed to do. Make that dev flow less awful so you don't have to say "by the way this PR depends on #123, I will change the target branch when that is merged" and nonsense like that.

ligarota 2 hours ago||
What the difference with just two PR with the second PR targeting the first one??
msalsas 3 hours ago||
I don't see the point of this. Just keep your PRs small.
pyth0 2 hours ago|
That is in fact the point of this. Split your large feature into smaller, more manageable PRs and have them still be connected within GitHub.
ymir_e 3 hours ago||
Lately I've seen a lot of people complaining about GitHub downtime, performance and overall quality.

Happy to see something in the right direction. I think they've woken up a bit. Still surprising how slow things can move at big companies.

Companies like Linear, Vercel, Zed and Cursor all seem to be looking at GitHub more aggressively though. I do suspect there will be more competition shortly.

pzmarzly 2 hours ago|
Does it work across forks, or is it same repo only (like gh-stack et al)?
cassidoo 2 hours ago|
Currently same repo only, fork support coming soon.
More comments...