glossaryGit Cherry-pick
A git command that applies the changes introduced by one or more existing commits from any branch onto the current HEAD, creating a new commit with the same changes but a different hash.
explanation
Cherry-picking is the surgical alternative to merging or rebasing entire branches. Instead of bringing every commit from a branch, exactly one commit is selected and its changes are applied to the current position. This is invaluable for hotfix backporting, where a fix committed on the main branch needs to be applied to a release branch without bringing the intervening feature commits. The command takes a commit hash and replays the diff of that commit against the current HEAD. If the diff applies cleanly, a new commit with the same author and message (by default) is created. If conflicts arise, they are resolved the same way as merge conflicts. Cherry-picking copies changes rather than moving them. The original commit remains in its source branch. This means cherry-picking the same commit to multiple branches creates multiple copies of the change, each with a different hash. For tracking purposes, git cherry-pick automatically appends the original commit hash to the cherry-picked message.
examples
git cherry-pick abc1234 # apply commit abc1234 to current HEADgit cherry-pick abc1234..def5678 # apply a range of commitsgit cherry-pick -n abc1234 # apply changes without committing (--no-commit)git cherry-pick --continue # continue after resolving conflictsgit cherry-pick --abort # abort the cherry-pick in progresshow git-agent helps
git-agent's consistent commit format makes cherry-pick source selection easier: each commit's subject line clearly states what it does, so you can identify the right commit to cherry-pick without reading the full diff. The structured messages also help downstream tools track cherry-picked commits across release branches.
brew install gitagenthq/brew/git-agentFAQ
Can cherry-picking introduce merge conflicts?Does git-agent support cherry-picking?What is the difference between cherry-pick and rebase --onto?