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

Re: Cherry picking instead of merges.

From
Björn Steinbrink <b.steinbrink@gmx.de>
Date
Jul 4, 2008, 00:10 UTC
Message-ID
<20080704001003.GA19053@atjola.homenet>
In-Reply-To
<20080703223949.GA23092@old.davidb.org>
On 2008.07.03 15:39:49 -0700, David Brown wrote:
Show 10 quoted lines
> On Thu, Jul 03, 2008 at 02:18:53PM -0700, Linus Torvalds wrote:
>
>> End result: you have a nice merge with nice history that actually
>> converges at a common point, but you effectively did the merge
>> resolution one commit at a time with cherry-picking (or "git rebase",
>> which is obviously just a convenient shorthand for cherry-picking
>> everything).
>
> I'm still not clear how the one-commit-at-a-time resolution gets
> recorded anywhere (except in the cherry-picking branch).

They don't get recorded. Git does not store how merges happened in some diffs or whatever, it just stores the end result. So what Linus suggested was to reuse the end result that you already have to create the merge commit.

Say you have 5 commits like this:
  A---B---C
   \
    D---E

Now there are two ways to get the changes from D and E ontop of C. The first one is cherry-picking, which leads to:

  A---B---C---D'---E'
   \
    D---E
The other one is merging:
  A---B---C---M
   \         /
    D---E---/

Of course, you should end up with the same tree either way. It's just a different way of getting towards that final state. So commit E' and commit M, while different commits, would point to the same tree object.

Now if you want to create that merge commit M, and already have E' (like you do, as you already did all those cherry-picks), you can use what Linus suggested. You start the merge, ignore any conflicts and just tell git to use the tree that E' is pointing to instead.

Björn
Previous: David BrownNext: David Brown
Message 8 of 13 in “Cherry picking instead of merges.”
  1. David BrownJul 3, 2008
  2. Alex RiesenJul 3, 2008
  3. Avery PennarunJul 3, 2008
  4. David BrownJul 3, 2008
  5. Samuel TardieuJul 3, 2008
  6. Linus TorvaldsJul 3, 2008
  7. David BrownJul 3, 2008
  8. Björn SteinbrinkJul 4, 2008
  9. David BrownJul 4, 2008
  10. Linus TorvaldsJul 4, 2008
  11. Johannes SixtJul 4, 2008
  12. Linus TorvaldsJul 4, 2008
  13. Linus TorvaldsJul 4, 2008

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.