Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Multiple commits cherry-picking

I have 33 commits in the main branch that are meshed up. Now I need to maintain the record neatly. So now I have created feature branches and I'm trying to classify those 33 commits in different feature branches. So can it be possible to pick multiple commits at a time to copy in the relevant feature branch? And I am also facing its conflicts when I tried multiple commits with the cherry-pick command.

git cherry-pick A B C 

here A, B, C are the commits' hashcode.

like image 860
Nitu Dhaka Avatar asked Dec 20 '13 07:12

Nitu Dhaka


People also ask

Do cherry pick multiple commits?

It is possible to cherry pick multiple commits using the command line. Git 1.7. 2 introduced the ability to cherry pick a range of commits.

Can you cherry pick a range of commits?

The thing is if you are cherry picking a range of commits, it will cherry pick the parent commits correctly but then when it hits a normal commit, it fails and says commit is not a merge.

How do you cherry pick multiple commits in Intellij?

Open the Git tool window Alt+9 and switch to the Log tab. Locate the commit containing the changes you want to cherry pick. on the toolbar). Select the required commit.


2 Answers

You do it correct. The synopsis is

git cherry-pick [--edit] [-n] [-m parent-number] [-s] [-x] [--ff] <commit>... 

git cherry-pick goes from left to right commit. You can order how you want. If you have a conflict you have three choices. you can git cherry-pick --quit (stop cherry-picking and let your tree in his current state), git cherry-pick --abort (stop cherry-picking and reset your branch to the state where he was before you start git cherry-pick) or resolve this conflict with an editor or with git mergetool and then git cherry-pick --continue go to next commit in your list.

like image 139
silvio Avatar answered Oct 05 '22 20:10

silvio


If you need to maintain the record neatly you are better off with creating a topic branch and running git rebase -i <commit before the 33rd>, an interactive rebase. Follow the instructions for dropping commits. This should be simpler than cherry-picking so many commits in a particular strict order.

like image 34
mockinterface Avatar answered Oct 05 '22 21:10

mockinterface