+2

Simplify rebase of a child branch to a newer version of parent branch

George Bessonov 10 months ago updated by Thomas Singer 10 months ago 0

There is a common workflow to have some big feature branch with every small ticket having it's own small branch.

Small tickets get merged into the feature branch in some way, the way isn't related to the request.

As an author of some ticket branch you want to keep up with the feature branch.

For merges of other ticket branches, it's the old plain rebase/merge.

But time has come to rebase the feature branch onto a fresh develop/main/master/... version.

Somebody performs the rebase and solves all the conflicts.

Then you have to rebase your branch onto it and here is the pain: you have to solve all the conflicts solved in the original feature branch again.

My proposal is to add an option to simplify this: when some old commit in your branch (b1) is pointed by a local branch (b2-loc) which is diverged from it's tracked branch (b2-rem) and you rebase your branch (b1) onto a commit pointed by the diverged remote (b2-rem), add an option to "rebase only your changes".

The simplest way this option can work is to create a temporary branch on b1, hard reset b1 onto b2-rem, cherry-pick every commit from the temp branch into the new b1, starting from the one which has b2-loc as a parent, delete the temporary branch.

I personally perform this routine pretty often and I would like to have an option to do this in a single click.

When I do so, it's also inconvenient to solve conflicts your changes have with b2-rem, because mass cherry-pick breaks on conflict and you have to search for the conflicted commit from your changes and select every commit after to continue your cherry-pick, repeat on every conflict.