logoalt Hacker News

GitHub Stacked PRs

857 pointsby ezekgyesterday at 8:36 PM480 commentsview on HN

Comments

solaire_oatoday at 1:19 AM

Pretty cool to see stacks being given due attention. Also check out git-spice, which works with Gitlab (possibly others). Personally I use git-spice in place of all the conventional git commands.

baalimagotoday at 6:23 AM

Sounds like a merge-conflict nightmare

throwatdem12311yesterday at 10:42 PM

Freaking finally.

I’ve been trying to convince my boss to buy Graphite for this, seems like Github is getting their a* in gear after Cursor bought them.

If Jetbrains ever implements support for them in IntelliJ I will be in Heaven.

prakashn27yesterday at 11:26 PM

Meta has something similar to this using mercurial. It was awesome.

vedant_awasthitoday at 10:11 AM

This is useful. Managing dependencies across PRs has always been tricky — nice to see better workflows evolving.

baqyesterday at 9:14 PM

Just when I’ve gotten used to having 3 or more PRs in parallel with a local octopus working tree with jj. Maybe my colleagues will see the light at least.

elAhmotoday at 10:08 AM

Hah, first time seeing github.github.com

nonoesptoday at 7:39 AM

First thing that came to mind was git butler.

lopsotronicyesterday at 10:35 PM

Interesting to see how this integrates with any release flows that use a lot of tags or feature flagging.

Liskni_sitoday at 2:14 PM

It's awesome that they're adding a UI for stacked branches¹! The UX of the CLI tool seems weird, though. Why do I need to explicitly create and add branches to the stack if all I really want is to open PRs from my commits? Here's the workflow that I built for myself instead:

∙ `git checkout -b feature-branch-xyz`

∙ make a few commits, perhaps some fixups, rebase, whatever

∙ start tig, look at the history, decide at which points I want to break the branch into stacked PRs, and mark those points using shift-s (which calls my own `git gh-stack branch create $commit` and creates a specially named branch there)

∙ `git gh-stack sync` — collects all the specially named branches, builds a graph of how they're stacked on one another, pushes them, opens stacked PRs

GitHub has had some "support" for stacked PRs for a while, so merging the first one to main will automatically change the target branch of the second to main.

If I need to change anything, I can just `git rebase --interactive --update-refs`, amend commits, split commits, rearrange commits, and then running `git gh-stack sync` will update the PRs for me. If I split a commit in the middle and shift-s to mark it, it will open an extra PR and restack everything to update the order.

Furthermore, the "PR stack" doesn't actually need to be a stack (linear chain), it can be a tree. If I know that some commits are independent of the rest, I don't need to create a separate stack, I just create another local branch, mark PR-ready commits with shift-s, and `git gh-stack sync` will do the right thing. If I need to rebase the whole tree on top of current main, then `git rebase -i --rebase-merges --update-refs` does the job.

I guess what I'm saying is that as someone who's been using git since its inception, it feels much more natural to just do everything in git, and then have a single command that pushes my work to GitHub. And I think this might work even better with jujutsu — just point `git gh-stack sync` at the branches jj makes and it'll make a stack/tree of PRs out of them. :-)

https://github.com/liskin/dotfiles/blob/home/bin/git-gh-stac... if anyone's curious. It's just a few hundred lines of code. Building the graph is done by `git log --simplify-by-decoration`. Opening PRs is shelled out to `gh pr create`.

¹) I mean, I'd much rather they added a UI for reviewing PRs commit-by-commit, with the option to approve/request-changes on each, and the possibility to merge the first few approved ones while continuing work on the rest… But in a world of almost every $dayjob insisting on squash-merging, a UI for stacked PRs is a total game changer, positively.

mc-seriousyesterday at 9:32 PM

great, I'll directly compare it to graphite.com - the main point really is the user interface in my opinion. Still a bit sceptical whether github can out-deliver here, but happy to be proven wrong!

Has anyone already tried that was a graphite user before?

silverwindyesterday at 11:14 PM

This needs to be supported on `git` level first imho, not by a forge vendor.

show 1 reply
jamesfishertoday at 11:25 AM

Reminder that if your agent can create PRs then it can merge them too: https://github.com/orgs/community/discussions/182732

ghighi7878yesterday at 9:26 PM

What's difference between stacked PRs and merge trains in gitlab?

show 1 reply
srvaroatoday at 6:33 AM

This feature is 10 years late

inetknghtyesterday at 8:47 PM

Cool. Now let me do it across multiple repos. I often end up with 10 or 20 PRs across a half dozen repos that need to be merged in specific order.

show 3 replies
balamatomtoday at 11:28 AM

Oh cool, soon people will stop being incapable of working with me.

vedant_awasthitoday at 10:14 AM

Interesting direction. Curious how this compares with traditional transformer-based approaches in real use cases.

ruinedtoday at 3:04 AM

man, why is this waitlisted. this should have been a feature 10 years ago

scottfitsyesterday at 9:40 PM

cherry picking is so fragile, this is at least a step in the right direction

teaearlgraycoldyesterday at 9:32 PM

Wondering how all of those startups that implement this for GitHub feel right now.

show 1 reply
lpeancovschitoday at 4:40 AM

this was released about 7 years ago, no?

whalesaladyesterday at 8:51 PM

At first I thought this was a user submitted project due to the subdomain of github.com but then realize the subdomain is also github. Is this an official channel for this sort of thing? Surprised this isn't on the official blog.

show 3 replies
latentdreamtoday at 12:51 AM

the Website for the release statement look soooooo bad

sylwaretoday at 1:06 PM

microsoft broke nearly all classic web support (noscript/basic (x)html).

Since I can still login, is there a web API (using CURL and some identifying session token I could retrieve from my login) I could use to actually do "something". For instance, be involved in the issues of some project?

(for me, that would be mostly valve stuff on linux based OSes)

Any pointers?

godzillafartsyesterday at 11:06 PM

“You cannot merge a PR in the middle of the stack before the PRs below it are merged.”

Huh? Some stacks need to land all at once and need to be reviewed (and merged) from the top down. It’s not uncommon, in my org at least, to review an entire stack and merge 3 into 2 and then 2 into 1 and then 1 into main. If 2 merges before 3, you just rebase 3 onto 1.

noidentyesterday at 8:47 PM

If only there were some way to logically break up large pull requests into smaller pieces... Some way of creating a checkpoint with a diff including your changes, and some kind of message explaining the context behind the change... some way to "commit" a change to the record of the repository...

show 5 replies
jen20yesterday at 11:00 PM

I'm surprised no-one has commented on the "sign up for the waitlist" button being a Microsoft Office form that wants your email address and GitHub handle. This feels like an elaborate phishing attack more than a serious feature announcement.

Pxtlyesterday at 10:48 PM

This feels like a workaround for git's contradictory ergonomics.

ChrisArchitectyesterday at 9:46 PM

Aside:

> This is a docs site that was made to share the spec and CLI for private preview customers that ended up getting picked up. This will move to GitHub docs once it’s in public preview.

(https://x.com/matthewisabel)

DesiLurkeryesterday at 9:25 PM

what happened to the old gerrit reviews, I loved its handling on incremental patchsets. github is primitive by comparison.

enraged_camelyesterday at 9:16 PM

The biggest challenge for us are PRs that need to be coordinated across multiple repos. API + client for example. It doesn't sound like stacked PRs solve that problem, right? Description specifically states single repo.

show 1 reply
the_gipsyyesterday at 10:16 PM

Can we merge from GitHub UI without rewriting the commit already?

sparin9today at 3:57 AM

[dead]

jiusanzhoutoday at 7:02 AM

[dead]

sameenkarimyesterday at 9:38 PM

[dead]

show 3 replies
jollifetoday at 6:59 AM

[dead]

TZubiriyesterday at 9:10 PM

github.github.com? Not the first time github does something highly weird with their domains (like publishing docs from a subdomain of their public github pages service)

I think they have a culture of circumventing 'official' channels and whoever is in charge of a thing is whoever publishes the thing.

I think it's a great way to train users to get phished by github impostors, if tomorrow we see an official download from official.github.com or even official-downloads.github.io, sure it's phishy, but it's also something that github does.

It's also 100% the kind of issues that, if it happens, the user will be blamed.

I would recommend github to stop doing this stuff and have a centralized domain to publish official communications and downloads from. Github.github.com? Come on, get serious.

TL;DR: DO NOT DOWNLOAD ANYTHING from this site, (especially not npm/npx/pnpm/bun/npjndsa) stuff. It's a Github Pages site, just on a subdomain that looks official, theoretically it might be no different from an attacker to obtain access to dksabdkshab.github.com than github.github.com. Even if it is official, would you trust the intern or whoever managed to get a subdomain to not get supply chained? github.github.com just think about it.

show 1 reply
bob1029yesterday at 9:07 PM

I feel like we already have enough abstractions in this space. Having any constraints at all in your tools is actually a good thing. PRs on top of ordinary git was a good step. This seems like one too many.

show 1 reply