0

We are using git rebase --onto to pick commits from a branch to another branch. Let's say from for simplicity the develop branch to the release branch.

1----A----B----C----D----2----3----E----F---G----H----4----5----6 develop

Out of the above I need to merge all of the "character" revisions from develop into release, it is important to note that I need to ignore the numeric revisions.

So what we do is run the rebase onto for each grouping. For example in the above there are 2 groupings, A to D and E to G.

git rebase --onto release 1 D #rebase the first range of revisions from the develop branch and base it on the release branch

git rebase --onto release 3 H #rebase the second range of revisions from the develop branch and base it on the release branch.

The problem is that for each grouping we need to run this command which is not convenient.

Is there any way that I could run git rebase --onto once and specify all the required revisions then in one single command

MilindaD
  • 7,533
  • 9
  • 43
  • 63
  • There are a lot of ways to do this, what you've got here is just the most inconvenient. Easiest might be interactive rebase and delete the ones you don't want. – jthill Mar 29 '16 at 19:10
  • Indeed, just `git rebase -i --onto release 1` followed by selecting the patches you want will work, if you don't mind doing it in EDITOR rather than at a shell. – amalloy Mar 29 '16 at 19:27
  • Rebase is the wrong tool for picking good ("cherry") commits from one branch into another. The `git cherry-pick` command does precisely that: you identify the cherries to pick, and it picks (copies) them. – torek Mar 29 '16 at 20:10

1 Answers1

3

Is there any way that I could run git rebase --onto once and specify all the required revisions then in one single command

I would suggest to use git cherry-pick instead.
Use the cherry-pick with a commit range and you can pass as many ranges as you wish

# set the range of commits you are interested in 
# A should be older than B.
cherry-pick A..D E...H

And it will merge the given ranges into your current branch

CodeWizard
  • 128,036
  • 21
  • 144
  • 167