What does cherry-picking a commit with Git mean?


What does git cherry-pick <commit> do?


Cherry-picking in Git means choosing a commit from one branch and applying it to another.

This contrasts with other ways such as merge and rebase which normally apply many commits to another branch.

It's also possible to cherry-pick multiple commits but merge is the preferred way over cherry-picking.

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

    git switch master
  2. Execute the following:

    git cherry-pick <commit-hash>


  1. If you cherry-pick from a public branch, you should consider using

    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 and may avoid merge conflicts in the future.

  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>

Additional links:

Install gitk on Mac

Git: Merge a Remote branch locally