[prev in list] [next in list] [prev in thread] [next in thread] 

List:       git
Subject:    Rebasing multiple branches at once
From:       Mike Hommey <mh () glandium ! org>
Date:       2016-12-31 8:14:33
Message-ID: 20161231081433.3zo6lrsjsu2qho4u () glandium ! org
[Download RAW message or body]

Hi,

I've had this kind of things to do more than once, and had to do it a
lot today, so I figured it would be worth discussing whether git-rebase
should be enhanced to support this, or if this should go in a separate
tool or whatever.

So here is what I'm trying to do in a not-too painful way:

I'm starting with something like this:
A---B---C---D---E
            \---F

where A is master, and E and F are two local topics with a common set of
things on top of master.

The next thing that happens is that master is updated, and I want to
rebase both topics on top of the new master.

So I now have:

A---G
\---B---C---D---E
            \---F

If I do the dumb thing, which is to do `git rebase master E` and `git
rebase master F`, I end up with:

A---G---B'---C'---D'---E'
    \---B"---C"---D"---F'

That is, I just lost the fast that E and F had common history.

I could go with `git rebase master E` followed by `git rebase --onto D'
D F` but that's cumbersome, especially when you have more than 2 topics,
not necessarily diverging at the same point (e.g. I might have another
topic that diverges at C)

So, what I end up doing is something like:
- git co -b merge E
- git merge --strategy ours F (and any other topic I might want to
  rebase)
- git rebase master --preserve-merges

If everything goes fine, then I can `git update-ref` the topics to each
parent of the merge branch.

But, usually, since rebase --preserve-merges redoes merges with the
default strategy, I end up with conflicts, and instead of trying to
figure stuff out, I just pick the rewritten sha1s from
.git/rebase-merge/rewritten/* to update the refs.

It is my understanding that the --strategy option to git-rebase is used
for the rebase itself, so I'm not sure there's a way to tell rebase to
use a specific strategy for the preserved merges only.

Anyways, it /seems/ like just allowing multiple branches on the git
rebase command line and make this work would improve things
significantly. The question then, is how would that interact with other
options (I'm thinking e.g. -i, but -i already has a problem with
--preserve-merges). But it does seem like it would be a worthwhile
improvement.

What do you think?

Mike
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic