Git & GitHub Interview Question #59

What is git cherry-pick?

Undo & Recovery, Tags, Forks, Pull Requests & Code Review Mid-Level Intermediate

Quick Interview Answer

git cherry-pick applies the changes introduced by one or more existing commits onto the current branch and creates new commit identities there.

Detailed Explanation

git cherry-pick applies the changes introduced by one or more existing commits onto the current branch and creates new commit identities there.

It is useful when a specific fix or change is needed without merging an entire branch. Excessive cherry-picking between long-lived branches can make history harder to understand, so it should be used intentionally.

Code Example

git switch release
git cherry-pick <commit-id>