Updating Stacked Pull Requests with git rebase --onto

13 points by BD103


cx

If you have stacked branches, it is sometimes easier to perform e.g. a fixup commit referencing any of the older commits while being on the tip of the branches, then using --update-refs on git rebase to make git automatically update all of the intermediate branches. This prints an update-ref command in the interactive rebase command list, which you can also use to toss commits over between the intermediate branches. Then you can git push --force-with-lease intermediate-branch-1 intermediate-branch-2 tip-branch to push the whole stack.

You can use this to rebase the entire stack to main at once without having to rebase the individual intermediates.

senekor

Mandatory recommendation of Jujutsu, which solves this problem by default: https://docs.jj-vcs.dev/latest/