0

I have a feature branch that has already been merged (in M) but reverted afterwards (in R):

S---o-o-----M-o-R-o
 \         /
  A-----B-C       ^ master

          ^ feature

I want to rebase the feature branch onto the current master so I get:

S---o-o-----M-o-R-o-A'-B'-C'
 \         /
  A-----B-C               ^ new master or new branch
                  ^ old master
          ^ feature

This is similar to the process described in the addendum of revert-a-faulty-merge.txt but instead of basing the new branch on S I want to base it on the current master.

According to this question this solution should work:

git rebase --onto stable D fix/123
This is still kind of risky because you need to take the SHA of D (and NOT X for instance).

So I tried git rebase --no-ff --onto master S feature but it just advanced the feature label to the master label and said "Fast-forwarded feature to master" without generating any new commits.

So how can I basically copy the whole feature branch on top of master?

Community
  • 1
  • 1
AndreKR
  • 32,613
  • 18
  • 106
  • 168
  • Out of curiosity, why do you want to do that? The commits A-C are already within the history, so copying them at the top of master would duplicate them, possibly confusing everyone looking at it. Instead you might want to apply a fix on the branch (to make it accepted on master) and then merge it again into master. – poke Jun 07 '13 at 13:35
  • They have been reverted some time ago (commit `R`, just like Linus describes in the linked text), so I need to merge them again after some modifications. – AndreKR Jun 07 '13 at 16:02

1 Answers1

4

git cherry-pick now supports a range of commits, like so:

git cherry-pick S..C

This will get the commits after S up through C. You can also specify to start from the parent of A, like so:

git cherry-pick A^..C
AndreKR
  • 32,613
  • 18
  • 106
  • 168
Wally Altman
  • 3,535
  • 3
  • 25
  • 33