git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[Discussion] cherry-picking a merge

From
Junio C Hamano <gitster@pobox.com>
Date
Nov 15, 2007, 08:00 UTC
Message-ID
<7v3av86iqa.fsf@gitster.siamese.dyndns.org>

Earlier "git cherry-pick" learned the "-m <parent-number>" option to allow cherry-picking a merge commit.

When you have this history:
  ---o---o---C---A---M
      \             /
       o---o-------B

You can replay the change between A and M (in other words, the effect of merging B into A) on top of C to create a new commit, with:

        $ git cherry-pick -m 1 M

In the current implementation, the resulting commit has a single parent C. This is quite similar to a squash merge of B into C.

When you think about it, as long as the topological relationship between A and B is very similar to that of C and B (iow, "merge-base A B" and "merge-base C B" are the same), the effect should be the same as a real merge between B and C, shouldn't it?

  ---o---o---C---A---M
      \       \     /
       o---o---\---B
                \   \
                 `---X

I am wondering if it makes sense to record the result of "cherry-pick -m" as a real merge between the current HEAD and all the other parents of the cherry-picked merge except the one that is named with the <parent-number>.

Next: Shawn O. Pearce
Message 1 of 3 in “[Discussion] cherry-picking a merge”
  1. Junio C HamanoNov 15, 2007
  2. Shawn O. PearceNov 15, 2007
  3. Junio C HamanoNov 15, 2007

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.