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

Re: Question about merge & cherry pick

From
Johannes Sixt <j6t@kdbg.org>
Date
Nov 7, 2024, 17:18 UTC
Message-ID
<eb3a25c0-7f43-4811-a9ad-0388f395b26e@kdbg.org>
In-Reply-To
<a129e967-efba-48ba-b5a0-1abbb0af5c9d@maurel.me>
Am 07.11.24 um 11:32 schrieb Julien Maurel:
Show 9 quoted lines
> Le 07/11/2024 à 07:37, Johannes Sixt a écrit :
>> A merge does not consider the individual changes on the branches, but
>> only the differences since the merge base. For the merge operation, the
>> change from Z to Y never happened on the dev side. The reversal of Y to
>> Z is not visible for the merge and cannot contribute to the result.
> 
> Ok, I didn't have this vision about how merge is apply, thanks.
> There is no option to merge by considering each commit individually ?
> Rebase do it but not applicable in my case :)
You can merge the dev branch in two steps:
          A Z Q E        initial commit
          /      \
      A Y Q E     |      dev: Z -> Y
         |\       |
         | \   A Y Q E   master: cherry-pick Z -> Y
         |  \     |
         |   A Y Q E     master: merge dev
         |        |
      A Z Q D     |      dev: revert Y -> Z and change E -> D
          \      /
          A Z Q D        merge again

The merge of dev into master changes the merge base of the final merge: it is the second commit in the diagram. Now there is no contribution to the merge from the master branch anymore, because its tip is identical to the merge base, and both changes made in the second commit on dev are visible and contribute to the merge result.

-- Hannes
Previous: brian m. carlson
Message 5 of 5 in “Question about merge & cherry pick”
  1. Julien MaurelNov 6, 2024
  2. Johannes SixtNov 7, 2024
  3. Julien MaurelNov 7, 2024
  4. brian m. carlsonNov 7, 2024
  5. Johannes SixtNov 7, 2024

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.