Git cherry-pick
Definition
Cherry-picking transfers the changes of selected Git commits to another current working state.
Cherry-picking applies the changes of one or more selected commits to the current Git state, usually creating new commits in the process. It selectively adopts changes instead of automatically merging an entire development line. Different starting points can cause conflicts or missing prerequisites.
Simply explained
You adopt a selected change without taking along all other changes from its original development branch.
Why it matters in practice
The procedure helps to selectively transfer individual bug fixes to other versions when a full merge is not appropriate.
Example from business
Example: A team adopts an already reviewed bug fix from the main branch into the maintenance branch of an older product version.
Limits and pitfalls
- The change may require additional commits. New commit identities and possible conflicts require traceable documentation as well as testing in the actual target state.
Origin & history
Cherry-picking is a targeted change adoption within version control and differs from merging complete development lines through a merge.
Use in mid-sized companies
- Companies can adopt individual fixes for supported product versions and deliberately check whether the change fits the respective target state.
Frequently asked questions
Does the same commit remain?
Usually, a new commit with its own identity is created because the change is adopted in a different context.
Sources
- git-cherry-pick. · Git (o. J.): git-cherry-pick.
Editorially reviewed on: