Difference between merge and cherry-pick in git

Generally, cherry picking in git means to choose a particular commit from one branch and apply it onto another. In contrast  merge or rebase apply normally many commits onto another branch.

If you are a console fan and do not use any graphical interfaces working with git, proceed as follow for cherry-pick:

  1. Make sure you are on the branch you want to apply the commit to.

    git checkout master

  2. Execute the following to pick a commit:

    git cherry-pick <commit-hash>

Also note following:

  1. If you cherry-pick from a public branch, you should better use

    git cherry-pick -x <commit-hash>

    This will generate a standardized commit message. This way, you and your co-workers can still keep track of the origin of the commit.

  2. If you have notes attached to the commit they do not follow the cherry-pick. To bring them over as well, You have to use:

    git notes copy <from> <to>

 

More about cherry-pick can be found at git official guide page.