Cherry-Picking: One Commit Without the Branch

Cherry-Picking: One Commit Without the Branch

21 October 2026 · By Laravel Git · 2 min read

A branch has ten commits and you need one of them - not the merge, not the history, just that change, on your branch. That is cherry-pick’s whole job.

The basic move#

Find the hash on the source branch, then apply it where you stand:

git log --oneline release/1.4
git switch main
git cherry-pick 332a818

Git replays that commit’s diff on your current branch and makes a new commit with the same message. Note the new commit gets a new hash: the parent is different, so it is a copy, not a move - the original still lives on its branch.

Record where it came from#

git cherry-pick -x 332a818

-x appends “(cherry picked from commit …)” to the message. Six weeks later, when the release branch and main both contain what looks like the same fix, that line is the difference between “already backported” and an hour of comparing diffs. Use it every time the source branch will keep existing.

When it fights back#

A cherry-pick can conflict exactly like a merge, usually because the surrounding code drifted between the branches. Resolve the files, then:

git cherry-pick --continue   # or: git cherry-pick --abort

--abort puts the branch back as if you never started, so a pick that is turning into a rewrite costs nothing to abandon.

The Laravel-shaped case#

A hotfix lands on main during the week; the release branch for 1.4 tags on Friday and needs that fix but none of the week’s other work. Cherry-pick it with -x, run the suite, tag. The release notes stay honest and the histories traceable.

Where it goes wrong#

Cherry-pick is for exceptions, and it turns sour as routine:

  • The same fix picked onto four branches is four divergent commits to reconcile later. If every active branch needs a change, land it on the oldest branch that needs it and merge forward instead.
  • Picking whole features commit-by-commit rewrites review history into a queue of conflicts. That is what rebases and merges are for.
  • Because the copy has a new hash, tooling that matches commits by hash - and teammates comparing branches - will see two commits. -x keeps that readable.

Used sparingly and always with -x, cherry-pick is the scalpel of the toolbox: not how you move work, exactly how you move one piece of it.

Share this post

Our network