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.
git cherry-pick says "...38c74d is a merge but no -m option was given" - Stack Overflow
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 fileMore on reddit.com
"Git cherry pick is bad practice" debate
How to Cherry-Pick in Git: The Easy Way
What is git cherry pick used for?
How do I cherry pick a commit in Git?
Can I cherry pick multiple commits in Git?
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.
-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.