Is it possible to rebase a branch with all its parent branches with Git? (I think "parent branches" is the correct form to use here. Depending on your viewpoint, you might also call them dependent sub-branches. Yet, following the parent-pointers of the commits will get you to those branches, so IMHO it is fair to call them "parent branches").
I often use branches as quick/mutable tags/checkpoints to mark certain commits. All parent branches/parent refs are fully included in the branch-to-be-rebased; there are no commits only in the parent branches.
* master
*
* featureA-finished
*
* origin/master
Now I want to rebase -i
master
onto origin/master
to change/reword the commit featureA-finished^
After git rebase -i --onto origin/master origin/master master
, I basically want the history to be:
* master
*
* featureA-finished
* (changed/reworded)
* origin/master
but what I get is:
* master
*
* (same changeset as featureA-finished)
* (changed/reworded)
| * featureA-finished
|.* (original commit i wanted to edit)
* origin/master
is there a way around it, or am I stuck with recreating all parent branches – more specifically the branch labels – on the new, rebased commits?
This question is related to, but still very different from Rebasing a branch including all its children.
Looks like this feature is slowly getting into Git. rebase
will gain the option --rebase-refs
which will do exactly what my original answer asked. For the proposed patch series see the thread rebase: command "ref" and options --rewrite-{refs,heads,tags} on gmane.
Update 2022:
The option --update-refs
has finally landed in Git v2.38.0, which can now do exactly what was asked in the initial question more than 12 years ago :)
This feature was merged with commit 3d8e3dc4fc22fe41f8ee1184f085c600f35ec76f in August. Hooray!