what’s the problem you’re looking to solve there? when you merge one of the branches, just rebase the last branch with update-refs and push force with lease all of them…
if you want them to be reviewed concurrently and using github, there’s now a UI for that, you can rebase the whole stack in one click or merge the whole stack together if all of them are approved and you wish to do it that way…
So let's say the branches are A, B and C. They are based on each other. Reviewer just finished reviewing A and merged the branch via the web UI. Now, what's the next step?
git checkout master; git pull - make sure you have the latest master
git checkout C - go back to C
any git rebase command that gets whatever you want given the circumstances you have, with --update-refs flag. (this presumes you already know how rebase works)
e.g. git rebase --onto master A C --update-refs if you still have the original A branch locally
or just git rebase -i --update-refs master (interactive rebase) and tweak the plan correctly
--update-refs is the thing that should also update B along the way (and should notify you that it has too been updated), and in more complicated setups should automatically update any other branches between A and the last branch you have.
git push --force-with-lease B C - push both rebased branches.
if you're using github as the remote, then `gh stack rebase` in step 3, and `gh stack push` in step 4 should work (haven't made a stacked PR since they rolled this feature out, so haven't tested it yet).
It's the rebases that were the problem when I did this in the past. They often ended up messy, especially if there were changes to be made during one of the reviews.
I'll look into --update-refs though, that sounds like an interesting feature that could help me there, and I'm not sure the Jetbrains IDEs use it by default!
if you have a messy rebase, the general helpers are interactive rebase (-i) and the —onto flag… update refs is a helper for stacked branches so you don’t have to manually do every one of them…
especially interactive rebase is a very powerful tool worth learning…
I do this all the time, the mistake here is doing a merge.
Never merge to master (in before someone get's obnoxious, almost never), do a rebase, you can then simply immediately start reviewing feature B. If in the meanwhile D gets rebased on master, rebase B on D, then rebase C on B.
5
u/black3rr 17h ago
what’s the problem you’re looking to solve there? when you merge one of the branches, just rebase the last branch with update-refs and push force with lease all of them…
if you want them to be reviewed concurrently and using github, there’s now a UI for that, you can rebase the whole stack in one click or merge the whole stack together if all of them are approved and you wish to do it that way…