Rebase a whole stack at once

You’re working on a series of PRs, one per branch, each one based upon the precediung one.

trunk -> my-feature-1 -> my-feature-2 -> my-feature-3 -> my-feature-4

Then you get a code review on my-feature-1 and you need to make a change. Now you need all the branches from my-feature-2 onwards to be rebased on the new my-feature-1 and for that to be reflected in your local.

$ git switch my-feature-4
$ git rebase --update-refs my-feature-1

--update-refs will save you having to go to each branch in turn and rebase.

Here’s an example git repo.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.