Back

Explore Courses Blog Tutorials Interview Questions
+4 votes
2 views
in DevOps and Agile by (29.3k points)
edited by

I have two branches. Commit a is the head of one, while the other has b, c, d, e and f on top of a. I want to move c, d, e and f to first branch without commit b. Using cherry-pick it is easy: checkout first branch cherry-picks one by one c to f and rebase the second branch onto first. But is there any way to cherry-pick all c-f in one command?

Here is a visual description of the scenario:

enter image description here

1 Answer

+4 votes
by (50.2k points)
edited by

According to git release note 1.7.2, it says that

* "git cherry-pick" learned to pick a range of commits(e.g. "cherry-pick A..B" and "cherry-pick --stdin"), so did "gitrevert"; these do not support the nicer sequencing control "rebase[-i]" has, though.

And there are certain things to take care of those are

1: A should be older than B. If they're in the wrong order the command will fail. 

2: Also, this will cherry-pick all except A  including B.  

3: To include A just type 

git cherry-pick A^..B

By considering this and you can achieve the desired output. For more details regarding git here is a tutorial that will help you regarding this concept.

Welcome to Intellipaat Community. Get your technical queries answered by top developers!

30.5k questions

32.5k answers

500 comments

108k users

Browse Categories

...