What is cherry-pick? How does it work?

Sometimes, merge of two branches might be nightmare.

Mehmet Nuri Abacı
Stormia Limited
2 min readJan 3, 2020

--

What a merge!

Click here for image reference

When you try to merge two different branches, there may be too many conflicts, commits do not want to be merged or anything to prevent merging. Don’t worry, just lay back and keep reading :)

What is cherry-pick?

Basically it means pick a commit you want to see in the other branch and apply into that branch.

The command is basic: git cherry-pick commit-sha

Let’s think a repository which has two different branches like below, and apply the command.

Initial repository:

Checkout to the master branch:

And, cherry-pick the commit f:

The result:

We have got only the commit f from the feature branch and mission is done! :)

The cherry-pick is a powerful command and incredibly useful when you need it. You can see more info in this link.

References:

--

--