mailing list mirror (one of many)
 help / Atom feed
From: Mike Hommey <>
Subject: Rebasing multiple branches at once
Date: Sat, 31 Dec 2016 17:14:33 +0900
Message-ID: <> (raw)


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:

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:


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


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
- 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

What do you think?


         reply index

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-10-16 12:17 Rebasing Multiple " Rick Moynihan
2008-10-16 13:59 ` Miklos Vajna
2008-10-16 14:48   ` Rick Moynihan
2008-10-16 21:00     ` Miklos Vajna
2008-10-17  2:00   ` Junio C Hamano
2008-10-16 13:59 ` David Kastrup
2008-10-16 14:57   ` Rick Moynihan
2008-10-16 15:02     ` Robin Burchell
2008-10-16 20:27 ` Toby Allsopp
2016-12-31  8:14 Mike Hommey [this message]
2017-01-01  2:40 ` Rebasing multiple " Junio C Hamano
2017-01-02  6:42   ` Jeff King
2017-01-01  8:42 ` Johannes Sixt

Reply instructions:

You may reply publically to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:

  List information:

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \ \ \ \

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link mailing list mirror (one of many)

Archives are clonable:
	git clone --mirror
	git clone --mirror http://ou63pmih66umazou.onion/git
	git clone --mirror http://czquwvybam4bgbro.onion/git
	git clone --mirror http://hjrcffqmbrq6wope.onion/git

Newsgroups are available over NNTP:

 note: .onion URLs require Tor:
       or Tor2web:

AGPL code for this site: git clone public-inbox