The way a cherry-pick works is by taking the diff a changeset represents (the difference between the working tree at that point and the working tree of its parent), and applying it to your current branch.

So, if a commit has two or more parents, it also represents two or more diffs - which one should be applied?

You're trying to cherry pick fd9f578, which was a merge with two parents. So you need to tell the cherry-pick command which one against which the diff should be calculated, by using the -m option. For example, git cherry-pick -m 1 fd9f578 to use parent 1 as the base.

Parent 1 is the "first parent", 2 is the "second parent", and so on. The order is the one in which they're listed in the commit (as viewed by git show and the like).

I can't say for sure for your particular situation, but using git merge instead of git cherry-pick is generally advisable. When you cherry-pick a merge commit, it collapses all the changes made in the parent you didn't specify to -m into that one commit. You lose all their history, and glom together all their diffs. Your call.

Answer from Borealid on Stack Overflow
🌐
Git
git-scm.com › docs › git-cherry-pick
Git - git-cherry-pick Documentation
The following sequence attempts to backport a patch, bails out because the code the patch applies to has changed too much, and then tries again, this time exercising more care about matching up context lines. $ git cherry-pick topic^ (1) $ git diff (2) $ git cherry-pick --abort (3) $ git cherry-pick -Xpatience topic^ (4) apply the change that would be shown by git show topic^. In this example, the patch does not apply cleanly, so information about the conflict is written to the index and working tree and no new commit results.
🌐
Atlassian
atlassian.com › git › tutorials › cherry pick
Git Cherry Pick | Atlassian Git Tutorial
December 15, 2025 - Maybe the backend developer creates a data structure that the frontend will also need to utilize. The frontend developer could use git cherry-pick to pick the commit in which this hypothetical data structure was created. This pick would enable the frontend developer to continue progress on their side of the project. When a bug is discovered it is important to deliver a fix to end users as quickly as possible. For an example scenario,say a developer has started work on a new feature.
Discussions

git cherry-pick says "...38c74d is a merge but no -m option was given" - Stack Overflow
You're trying to cherry pick fd9f578, which was a merge with two parents. So you need to tell the cherry-pick command which one against which the diff should be calculated, by using the -m option. For example, git cherry-pick -m 1 fd9f578 to use parent 1 as the base. More on stackoverflow.com
🌐 stackoverflow.com
Newbie - How does a cherry pick merge conflict occur?

If you think of a cherry pick as something that is simply adding more code, then it's not obvious why a cherry pick would ever cause a conflict. But remember that a commit includes stuff that is being added and stuff that is being removed.

Say that you have a file which contains the following text:

Hello this is a file

And at this stage, you try to cherry pick a commit which is trying to remove the text:

Hi this is NOT a file

And replace it with:

Hi this is a file

Git won't know how to apply this change because you're asking git to remove "Hi this is NOT a file" but that's not what the file contains, instead it contains "Hello this is a file".

At this point git will give you a conflict between:

Hello this is a file

And

Hi this is a file   
More on reddit.com
🌐 r/git
5
11
August 2, 2017
"Git cherry pick is bad practice" debate
cherry picking violates nothing, but your argument against code reviews has nothing to do with cherry pick and it's nonsense, if you have an issue against code reviews take that subject on its own, don't try to circumvent what's been the agreed procedure by your team More on reddit.com
🌐 r/git
30
3
July 29, 2024
How to Cherry-Pick in Git: The Easy Way
You can also cherry-pick a range of commits either by using the .. notation or by appending ^- to the merge commit id More on reddit.com
🌐 r/git
6
0
June 19, 2024
People also ask

What is git cherry pick used for?
The git cherry-pick command allows you to select a specific commit from one branch and apply it to another branch without merging the entire branch.
🌐
golinuxcloud.com
golinuxcloud.com › home › devops › git › git cherry pick explained with examples (single & multiple commits)
Git Cherry Pick Explained with Examples (Single & Multiple Commits) ...
How do I cherry pick a commit in Git?
First identify the commit hash using `git log`, then run `git cherry-pick ` on the target branch where you want to apply the commit.
🌐
golinuxcloud.com
golinuxcloud.com › home › devops › git › git cherry pick explained with examples (single & multiple commits)
Git Cherry Pick Explained with Examples (Single & Multiple Commits) ...
Can I cherry pick multiple commits in Git?
Yes. You can cherry-pick multiple commits by specifying multiple commit hashes or by using a commit range such as `git cherry-pick A^..B`.
🌐
golinuxcloud.com
golinuxcloud.com › home › devops › git › git cherry pick explained with examples (single & multiple commits)
Git Cherry Pick Explained with Examples (Single & Multiple Commits) ...
🌐
GitLab
docs.gitlab.com › topics › git › cherry_pick
Cherry-pick changes with Git | GitLab Docs
Use the git cherry-pick command with the -m option and the index of the parent commit you want to use as the mainline. Replace <merge-commit-hash> with the SHA of the merge commit and <parent_index> with the index of the parent commit. The index starts from 1. For example:
🌐
Medium
medium.com › @hamida.meknassi › cherry-picking-from-a-merge-request-commit-git-cherry-pick-m-de5be4e1f286
Cherry-picking from a Merge request commit : git cherry-pick -m | by Hamida Meknassi | Medium
February 20, 2024 - Cherry-picking from a Merge request commit : git cherry-pick -m This is rather a short one, to document, to easily search for and understand. Let’s get in to it ! Cherry picking in Git involves …
🌐
Git Tower
git-tower.com › learn › git faq › git cherry pick - how to use the "cherry-pick" command in git
Git Cherry Pick - How to use the "cherry-pick" command in Git | Learn Version Control with Git
For example, say commit C on a feature branch adds file3.txt (while earlier commits A and B added file1.txt and file2.txt): feature: A---B---C | C adds file3.txt main: X---Y | (HEAD)
Published   1 week ago
🌐
DataCamp
datacamp.com › tutorial › git-cherry-pick
Git Cherry-Pick: How to Select and Apply Specific Commits | DataCamp
March 5, 2025 - Each example illustrates how to apply the changes from one or more commits to another branch. Let’s say you’ve made a fix on a feature branch that you want to apply to the main branch without merging the entire feature branch. First, find the hash of the commit you want to cherry-pick by running: ... Locate the commit’s hash. ... When you run this command, Git will apply the changes from the commit identified by abc1234 to your current branch (which is main in this case).
Find elsewhere
Top answer
1 of 6
986

The way a cherry-pick works is by taking the diff a changeset represents (the difference between the working tree at that point and the working tree of its parent), and applying it to your current branch.

So, if a commit has two or more parents, it also represents two or more diffs - which one should be applied?

You're trying to cherry pick fd9f578, which was a merge with two parents. So you need to tell the cherry-pick command which one against which the diff should be calculated, by using the -m option. For example, git cherry-pick -m 1 fd9f578 to use parent 1 as the base.

Parent 1 is the "first parent", 2 is the "second parent", and so on. The order is the one in which they're listed in the commit (as viewed by git show and the like).

I can't say for sure for your particular situation, but using git merge instead of git cherry-pick is generally advisable. When you cherry-pick a merge commit, it collapses all the changes made in the parent you didn't specify to -m into that one commit. You lose all their history, and glom together all their diffs. Your call.

2 of 6
270

-m means the parent number.

From the git doc:

Usually you cannot cherry-pick a merge because you do not know which side of the merge should be considered the mainline. This option specifies the parent number (starting from 1) of the mainline and allows cherry-pick to replay the change relative to the specified parent.

For example, if your commit tree is like below:

- A - D - E - F -   master
   \     /
    B - C           branch one

then git cherry-pick E will produce the issue you faced.

git cherry-pick E -m 1 means using D-E, while git cherry-pick E -m 2 means using B-C-E.

🌐
GeeksforGeeks
geeksforgeeks.org › git › git-cherry-pick
Git - Cherry Pick - GeeksforGeeks
January 16, 2026 - The orange commit from Another Branch has been cherry-picked and applied to the Main Branch. This is visually represented by the red arrow labeled "CherryPick". ... Main branch receives the same changes with a new commit hash.
🌐
Medium
medium.com › @314rate › mastering-git-cherry-pick-advanced-guide-with-real-world-examples-3df3d9f284f5
Mastering Git Cherry-Pick: Advanced Guide with Real-World Examples | by 314rate | Medium
October 8, 2024 - For example, you might cherry-pick a security patch from the upstream repo: ... Explanation: This command fetches the latest changes from the upstream repository and applies only the selected commit to your local branch.
🌐
GoLinuxCloud
golinuxcloud.com › home › devops › git › git cherry pick explained with examples (single & multiple commits)
Git Cherry Pick Explained with Examples (Single & Multiple Commits) | GoLinuxCloud
March 16, 2026 - Learn how to use the git cherry-pick command with practical examples. This guide explains how to cherry-pick a commit, apply multiple commits, resolve conflicts, continue or abort cherry-pick operations, and safely move commits between branches in Git.
🌐
GitKraken
gitkraken.com › home › learn › what is the git cherry pick command?
Git Cherry Pick - How to Cherry Pick a Commit in Git | Learn Git
March 26, 2026 - You can easily see all of your commits listed in chronological order, with your most recent commit on the top. There’s no need to run a command to display your graph, and you don’t even have to obtain the SHA for your target commit. GitKraken will take care of all of that for you. In this cherry pick example, let’s say you have one branch—feature-A—checked out, and you commit your changes to said branch using the commit panel.
🌐
CloudBees
cloudbees.com › blog › git-cherry-pick-getting-the-exact-commit-you-want
Git Cherry Pick: Getting the Exact Commit You Want
August 12, 2021 - Git cherry pick - the change has been added to the stage but not yet committed · You’re now free to add more changes before committing. You’re not restricted to using a hash to identify the commit you want to cherry-pick. Instead, you can use other references that “resolve” to a commit id, such as branch names or tags. For instance, consider our first example.
🌐
Codecademy
codecademy.com › docs › git › cherry pick
Git | Cherry Pick | Codecademy
October 20, 2023 - In the example below, The --no-commit option will apply the changes from the cherry-pick to the working directory, but it will not create a new commit. This allows developers to inspect the changes and make any necessary edits before committing the final changes to the main branch. # Switch to the `adding-content-about-dogs` branch. git checkout adding-content-about-dogs # Cherry-pick the commit with the SHA `2f410g1`, but do not commit the changes.
🌐
TheServerSide
theserverside.com › blog › Coffee-Talk-Java-News-Stories-and-Opinions › Need-to-git-cherry-pick-a-commit-Heres-an-example-how
How to git cherry-pick a commit example
We will begin this git cherry-pick example with a completely clean repository, which means first you will create a new folder, which we will name git cherry-pick tutorial, and then issuing a git init command from within it.
🌐
Opensource.com
opensource.com › article › 21 › 3 › git-cherry-pick
3 reasons I use the Git cherry-pick command | Opensource.com
April 2, 2021 - On the feature1 branch, run a git log command, and copy the commit hash that you want to cherry-pick. You can see a series of commits resembling the code sample below. The alphanumeric code following "commit" is the commit hash that you need to copy. You may choose to copy the first six characters (966cf3 in this example) for the sake of convenience:
🌐
Git
git-scm.com › docs › git-cherry
Git - git-cherry Documentation
$ git log --graph --oneline --decorate --boundary origin/master...topic * 7654321 (origin/master) upstream tip commit [... snip some other commits ...] * cccc111 cherry-pick of C * aaaa111 cherry-pick of A [... snip a lot more that has happened ...] | * cccc000 (topic) commit C | * bbbb000 ...
🌐
Unstop
unstop.com › home › blog › git cherry pick command | uses & more with examples
Git Cherry Pick Command | Uses & More With Examples
January 27, 2025 - Next, put the commit hash of each commit you want to apply after the git cherry-pick command. For example- git cherry-pick <commit-hash-1> git cherry-pick <commit-hash-2> git cherry-pick <commit-hash-3> ...
🌐
YouTube
youtube.com › the modern coder
Git CHERRY PICK Tutorial - YouTube
Learning any Git technique can be this easy:https://learngit.io/Newsletter readers get my videos early: https://newsletter.themoderncoder.com/-----What is Gi...
Published   December 19, 2022
Views   112K
🌐
LoginRadius
loginradius.com › home
How to use Git Cherry Pick
January 31, 2026 - For example, let's say a developer has started working on a new feature. During the development of a new feature, they find an existing bug. The developer creates an explicit commit to fix this bug.
🌐
Hatica
hatica.io › blog › git-cherry-pick-commands
6 Git Cherry Pick Commands & How To Use Them? - Hatica
June 27, 2023 - The basic cherry-pick command allows you to apply a specific commit from one branch onto another branch. Unlike merge or rebase, git cherry-pick enables granular integration of changes without merging the entire branch.