Repaso
EspaƱol
Maven, Git & SDLCIntermediateVCS-15

What does git cherry-pick <commit> do?

Options

  1. Deletes a commit from the history of the branch
  2. Applies one commit from another branch onto yours (Correct option)
  3. Merges the entire other branch into your branch
  4. Renames the current branch in the local repository

Answer

Applies the changes of one specific commit from another branch onto your current branch as a new commit

Why

Sometimes you want just ONE commit from another branch, for example a bug fix made on develop that must also go to release/1.2.

git cherry-pick <hash> copies that commit's changes onto your current branch, creating a new commit with a different hash.

Use it sparingly: duplicated commits can confuse history later.

Remember

cherry-pick = copy one commit to here.

Key terms

Practice this question in Repaso