Some changes exist on exactly one branch — a fix that applies equally to main and to a release line, one commit from a feature you do not want wholesale. git cherry-pick copies a single commit onto your current branch: same change, new commit, new hash, no history surgery.

The basic pick #

Take one commit from elsewhere
$ git switch release/v1.4
$ git cherry-pick f3e2d1c
[release/v1.4 a7b8c9d] fix: correct cache headers on media
 1 file changed, 2 insertions(+), 2 deletions(-)

Git applies the commit's diff on top of your branch and creates a new commit — same message, same author, new identity. The original branch is untouched.

The routine cases #

SituationFlow
Hotfix must reach main and the release lineFix on main, cherry-pick to release
One commit of a feature is needed nowPick it; the rest waits
A teammate's branch has the fix; merge is prematurePick that commit only
Rebuilding a lost branchPick survivors one by one

The hotfix flow is the canonical one — fix once on main, propagate deliberately:

Fix forward and backport
$ git switch main
  # ... fix, test, commit (f3e2d1c), push ...
$ git switch release/v1.4
$ git cherry-pick f3e2d1c

Conflicts and options #

A pick conflicts like any apply when the surrounding code differs between branches:

Resolve, continue, or bail
$ git cherry-pick f3e2d1c
CONFLICT ...
$ # ... edit, git add ...
$ git cherry-pick --continue
$ git cherry-pick --abort       # return to the starting point
OptionEffect
-n / --no-commitApply changes to the tree without committing
-xAppend "(cherry picked from ...)" to the message
--continue / --abortDrive a conflicted pick

-x is the traceability flag: the message records the origin commit, so future merges between the branches can recognise the change and skip duplicating it. -n is for picking several commits into one, or amending before committing — a rebase -i flavour of cherry-picking.

Finding the right commit to pick is log and bisect work. The Git series continues.