Menu
Coddy logo textTech

Git Cherry-pick

Last updated

git cherry-pick copies the changes from one or more specific commits and applies them onto your current branch as new commits. It's how you grab a single fix from another branch without merging that whole branch - useful for backporting a hotfix or pulling one commit out of a feature branch.

Try these in the terminal playground - a real shell in your browser, nothing to install.

Syntax

CommandWhat it does
git cherry-pick <hash>Apply one commit onto the current branch
git cherry-pick <a> <b>Apply several commits in order
git cherry-pick <a>..<b>Apply a range of commits (excluding a)
git cherry-pick -n <hash>Apply the changes but don't commit yet
git cherry-pick -x <hash>Note the original commit in the message

During a cherry-pick

If a cherry-pick hits a conflict, resolve it and continue.

CommandWhat it does
git cherry-pick --continueResume after resolving conflicts
git cherry-pick --abortCancel and restore the branch
git cherry-pick --skipSkip the current commit

Git cherry-pick FAQ

What does git cherry-pick do?
It takes the changes introduced by a specific commit and applies them onto your current branch as a brand-new commit (with a new hash). Unlike merge or rebase, it doesn't bring over a whole branch - just the commit or commits you name.
When should I use cherry-pick?
Use it when you need one particular commit somewhere else - for example, backporting a bug fix from main to a release branch, or pulling a single useful commit out of a feature branch without merging everything. If you want the entire branch, use merge or rebase instead.
How do I cherry-pick multiple commits?
List them: git cherry-pick <a> <b> <c> applies each in order. For a contiguous range use git cherry-pick <start>..<end>, which applies every commit after start up to and including end. Add <start>^..<end> if you want to include start itself.
What if a cherry-pick causes a conflict?
Git pauses and marks the conflicted files. Resolve them, git add the results, then run git cherry-pick --continue. To back out entirely, use git cherry-pick --abort, which restores your branch to the state before the cherry-pick started.
Can I practice this online?
Yes. Open the terminal playground to run git cherry-pick in a real shell in your browser - nothing to install. Coddy's free interactive Git course also covers moving commits between branches step by step.
Coddy programming languages illustration

Learn Git with Coddy

GET STARTED