Skip to content
Guides5 min read

How Git Cherry-Pick Works: Backport Hotfixes Without Branch Drift

Apply specific bug-fix commits across release branches cleanly using git cherry-pick -x, handle cherry-pick conflicts in 3-way view, and avoid duplicate history.

GitKron EngineeringUpdated

When git cherry-pick is the right tool (and when to avoid it)

Cherry-picking copies the diff introduced by an existing commit and applies it as a brand-new commit onto your current branch. It shines when backporting an urgent production hotfix from main onto a maintenance release/2.4 branch without pulling in unfinished feature work.

Avoid using cherry-pick as a substitute for normal feature merges—copying dozens of commits between active branches creates duplicate diffs with different SHA hashes that cause avoidable merge conflicts later.

# Switch to the target release branch:
git switch release/2.4

# Cherry-pick a commit and record its original SHA in the message (-x):
git cherry-pick -x a1b2c3d4

# Stage changes without committing immediately:
git cherry-pick --no-commit a1b2c3d4

Resolving cherry-pick conflicts cleanly

If the target release branch refactored surrounding lines, Git pauses the cherry-pick for conflict resolution. Opening the repository in GitKron launches the 3-way merge editor showing the parent commit, release branch, and cherry-picked hunk side by side.

  • Always pass -x on release backports so audit trails record "(cherry picked from commit ...)".
  • Cherry-pick commits in chronological order (oldest to newest) when applying a multi-commit range.
  • Right-click any commit node in GitKron’s Visual Commit Graph to cherry-pick with instant conflict preview.

Frequently asked questions

What does git cherry-pick -x do?

The -x flag appends a "(cherry picked from commit <sha>)" line to the commit message, making it easy for teammates and audit logs to trace where a backported fix originated.

How do I abort a cherry-pick that has conflicts?

Run git cherry-pick --abort (or click Abort in GitKron’s merge bar) to reset your working tree back to the clean state before the cherry-pick started.

All articles