• Pricing
DashboardContact Sales
  • Blogs
  • Discover
  • Docs
  • Community
  • AgentBeta
⌘K

Over 80,000,000 Cloud Servers Launched

Over 80,000,000 Cloud Servers Launched

Cloud ComputeCloud GPUBare MetalFile SystemObject StorageBlock StorageManaged DatabasesCDNServerlessKubernetesContainer RegistryDirect ConnectLoad Balancers
RegionsAdvanced NetworkControl PanelOperating SystemsUpload ISO
Industry CloudOne-Click DeploymentUse Cases
Browse AppsBecome a Vendor
FAQDevelopers / APIsVultr DocsServer StatusBug BountyPromotionsSolution PartnersStart-Up Programs
Our TeamNewsBrand AssetsReferral ProgramCreator ProgramCareersSLALegalVultr Trust CenterContactYour Privacy ChoicesSubprocessorsAccessibility
Contact SalesSign Up

© Vultr 2026 | VULTR is a registered trademark of The Constant Company, LLC.

Terms of ServiceAUPDMCAPrivacy PolicyCookie Policy

In this Article

The Short Answer VersionCherry-Pick a Single CommitCherry-Pick Multiple CommitsHandling Cherry-Pick ConflictsUndoing a Cherry-PickConclusion
  1. Docs
  2. Articles & Guides
  3. Development

How to Cherry Pick Commits in Git

4 min readUpdated 30 July 2025
0 comments
How to Cherry Pick Commits in Git header image

When managing code with Git, you often work across multiple branches. Sometimes, you need a specific change from one branch but don't want to merge the entire branch's history. Git's cherry-pick command allows you to select and apply a specific commit from one branch onto another. This is different from merging or rebasing, which integrate entire branches. With cherry-pick, you precisely select only the commits you need.

This article explains how to use git cherry-pick to apply single or multiple commits, handle conflicts, and undo changes when necessary.

The Short Answer Version


# Apply a specific commit to your current branch
$ git cherry-pick <commit-hash>

# Apply a range of commits (from start-commit to end-commit)
$ git cherry-pick <start-commit-hash>^..<end-commit-hash>

# Apply multiple, non-consecutive commits
$ git cherry-pick <hash1> <hash2>

# Abort a cherry-pick that has conflicts
$ git cherry-pick --abort

# Continue a cherry-pick after resolving conflicts
$ git cherry-pick --continue

Cherry-Pick a Single Commit

Cherry-picking is ideal when you need to transfer a single, specific change—such as a hotfix or a small feature—from one branch to another without merging all the other changes from that branch.

Command Syntax

git cherry-pick <commit-hash>
  • <commit-hash>: The unique identifier (SHA-1 hash) of the commit you want to apply.

Command Demonstration

  1. Identify the commit you want to cherry-pick, check out the branch that contains the commit.

    CONSOLE
    $ git checkout feature-branch
    Powered by Vultr AgentBeta
  2. Use git log to find the commit's hash.

    CONSOLE
    $ git log --oneline
    Powered by Vultr AgentBeta

    Output:

    a1b2c3d Fix critical bug
    d4e5f6a Add new feature
    g7h8i9j Initial commit

    Copy the hash of the commit you need, for example, a1b2c3d.

  3. Switch to the target branch where you want to apply the commit.

    CONSOLE
    $ git checkout main
    Powered by Vultr AgentBeta
  4. Cherry-pick the commit using its hash.

    CONSOLE
    $ git cherry-pick a1b2c3d
    Powered by Vultr AgentBeta

    The command above applies the changes from commit a1b2c3d to the main branch, creating a new commit with the same content and message, but a different hash.

Cherry-Pick Multiple Commits

In addition to applying a single commit, you can cherry-pick a sequence of commits or select multiple specific commits. This is useful when you need to transfer a set of changes without merging an entire branch.

Cherry-Pick a Range of Commits

To apply a series of consecutive commits from another branch, use the .. notation.

Command Syntax

git cherry-pick <start-commit-hash>^..<end-commit-hash>
  • <start-commit-hash>^: The ^ symbol tells Git to start from the commit before the specified start commit.
  • <end-commit-hash>: The last commit in the range to be applied.

Command Demonstration

To apply the last two commits from feature-branch to main:

CONSOLE
$ git cherry-pick d4e5f6a^..a1b2c3d
Powered by Vultr AgentBeta

The command above applies commits starting from d4e5f6a to a1b2c3d to the main branch in the same order.

Cherry-Pick Specific Commits

To apply multiple, non-consecutive commits, list their hashes in the order you want them applied.

Command Syntax

git cherry-pick <hash1> <hash2> <hash3>

Command Demonstration

To apply only the specific commits from a branch:

CONSOLE
$ git cherry-pick g7h8i9j a1b2c3d
Powered by Vultr AgentBeta

This command applies the changes from commits g7h8i9j and a1b2c3d to the current branch, in the specified order, while skipping the other commit.

Handling Cherry-Pick Conflicts

A conflict occurs if the changes in the cherry-picked commit overlap with changes in your current branch. Git will pause the process and ask you to resolve the conflict manually.

  1. When a conflict occurs, git status will show the conflicted files.

    CONSOLE
    $ git status
    Powered by Vultr AgentBeta

    Output:

    On branch main
    You are currently cherry-picking commit a1b2c3d.
      (fix conflicts and run "git cherry-pick --continue")
      (use "git cherry-pick --abort" to cancel the cherry-pick operation)
    
    Unmerged paths:
      (use "git add <file>..." to mark resolution)
            both modified:   config.yml
  2. Open the conflicted file in a text editor. Look for the conflict markers (<<<<<<<, =======, >>>>>>>), edit the file to keep the correct code, and remove the markers.

  3. After resolving the conflict, stage the modified file.

    CONSOLE
    $ git add config.yml
    Powered by Vultr AgentBeta
  4. Continue the cherry-pick process.

    CONSOLE
    $ git cherry-pick --continue
    Powered by Vultr AgentBeta

    If you prefer to cancel the cherry-pick and return to the previous state, run:

    CONSOLE
    $ git cherry-pick --abort
    Powered by Vultr AgentBeta

Undoing a Cherry-Pick

If you make a mistake during cherry-picking, you can undo the changes in two ways depending on whether the commit has been pushed to a remote repository.

  • If you have not pushed the commit to a remote repository, you can remove it from your local history using git reset.

    CONSOLE
    $ git reset --hard HEAD~1
    Powered by Vultr AgentBeta

    This above command discards the most recent commit and any uncommitted changes in your working directory. Use it with caution.

  • If you have already pushed the cherry-picked commit, avoid rewriting history. Instead, use git revert to create a new commit that reverses the changes.

    CONSOLE
    $ git revert <cherry-picked-commit-hash>
    Powered by Vultr AgentBeta

    This command creates a new commit that reverts the changes introduced by the specified cherry-picked commit, preserving your history and avoiding conflicts with collaborators.

Conclusion

In this article, you learned how to use git cherry-pick to apply specific commits from one branch to another. You now know how to pick single or multiple commits, resolve conflicts, and undo a cherry-pick. This command gives you precise control over your repository's history, making it an essential tool for managing complex workflows like hotfixes and selective feature integration.

Tags:Git

Tech Talk: Running a Self-Improving AI Agent with Hermes on Vultr

Have a suggestion or found an issue with this article?

About the Author

RD

Radadiya Dipali

View Profile
View Profile

More to Explore

Show More
tech-talk-thumbnail

Tech Talk: Running a Self-Improving AI Agent with Hermes on Vultr

tech-talk-thumbnail

Tech Talk: Implementing Fine-Grained Access Control with Vultr IAM

tech-talk-thumbnail

Tech Talk: Getting Started with Vultr IAM

tech-talk-thumbnail

Tech Talk: Simplifying Zero-Trust Networking with NetBird on Vultr Marketplace

Show More

0 Comments

Start the conversation

Be the first to comment and share your perspective with the community.