3

If I have a set of branches with common ancestor commit a, is there an easy way to rebase all of them onto commit b (where the common ancestor of a and b might be some third commit c)?

rampion
  • 87,131
  • 49
  • 199
  • 315
  • Are you trying to rebase the commits since `a` on each branch, or the commits since `c` on each branch? – Lily Ballard Feb 08 '12 at 20:47
  • See also [how I'd rebase a whole subhistory -- several branches, with some links between them resulting from merge](http://stackoverflow.com/a/9706495/94687). The unpleasant part of that solution is the need to reset the topic branch refs to the new rebased commits afterwards. – imz -- Ivan Zakharyaschev Mar 14 '12 at 22:04

1 Answers1

4

Yes. Just rebase them all.

If you anticipate repeated conflicts, enable git-rerere, which records your conflict resolutions and is able to automatically apply the same resolution when merge encounters the exact same conflicts in another (re)merge.

Or you could,

  1. Isolate commit a in a branch

     git checkout -b temporary <commita>
    
  2. Rebase the temporary branch onto commit b.

  3. Rebase all the 'related' branches onto the resulting branch temporary

sehe
  • 374,641
  • 47
  • 450
  • 633