git cherry-pick
Cherry-pick applies a specific commit from any branch onto your current branch. You are selecting exactly the change you want without merging the entire source branch. Perfect for applying hotfixes or extracting useful changes from unfinished work.
01.When Cherry-Pick Saves the Day
Common real-world scenarios: A critical security fix was committed to a feature branch — you need it on main and on the release branch right now. You accidentally committed to the wrong branch and need to move that one commit. A teammate wrote a useful utility function on their branch and you want it without taking all their WIP code.
02.Cherry-Pick Creates New Commits
Cherry-pick always creates a brand new commit with a new SHA hash — the content is identical to the original but the metadata differs (hash, timestamp, parent pointer). The original commit is NOT moved or deleted. If conflicts occur during cherry-pick, resolve them the same way as merge conflicts, then run git cherry-pick --continue.
Commands
What happens to the original commit after cherry-picking it?