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

Re: cherry picking and merge

From
Jakub Narębski <jnareb@gmail.com>
Date
Aug 1, 2014, 16:27 UTC
Message-ID
<53DBBFE8.8060607@gmail.com>
In-Reply-To
<20140801024329.GA28914@vauxhall.crustytoothpaste.net>
W dniu 2014-08-01 04:43, brian m. carlson pisze:
> On Thu, Jul 31, 2014 at 05:58:17PM -0700, Mike Stump wrote:
Show 21 quoted lines
>> Cherry picking doesn’t work as well as it should.  I was testing on
>> git version 1.7.9.5.
>>
>> Put in a line in a file, call it:
>>
>> first version
>>
>> then cherry pick this into your branch. Then update on master and transform that into:
>>
>> second version
>>
>> then, merge that branch back to master.  Death in the form of conflicts.
>>
>> In gcc land, I do this sort of thing all the time, and I need a
>> merging subsystem to actually keep track of things.  I can manage this
>> will diff and patch and it works flawlessly.  The point of using
>> something better than diff and patch is for it to be better than diff
>> and patch.
>>
>> I’d like for merge to merge in the work that has yet to be merged.
>> Not that, plus blindly try and apply or reapply cherry picked items.

Note that you should try to avoid cherry-picking, as they do not leave trace in the graph of revisions.

For example if you are creating a bugfix, instead of putting it directly on maint, and then cherry-picking to master, it is better to create a separate feature branch for this fix (based at an early version), and then merge said branch into maint, then into master. It is described in blog post by Junio Hamano (which I cannot find now).

Show 12 quoted lines
> You're not the first person to be surprised by the way merge works.
>  From the git-merge manpage:
>
>    [This behavior] occurs because only the heads and the merge base are
>    considered when performing a merge, not the individual commits.
>
> (That was added after 1.7.9.5.)
>
> If you want the behavior of applying multiple patches in a row, you want
> to use git rebase, not git merge.  Since rebase re-applies the patches
> of each of your commits on top of another branch, the identical change
> won't cause conflicts.

There is also git-imerge, third party tool that is intended to help merging changes (and make it possible to do it in incremental way).

HTH
-- 
Jakub Narębski
Previous: brian m. carlsonNext: Mike Stump
Message 3 of 43 in “cherry picking and merge”
  1. Mike StumpAug 1, 2014
  2. brian m. carlsonAug 1, 2014
  3. Jakub NarębskiAug 1, 2014
  4. Mike StumpAug 1, 2014
  5. Philip OakleyAug 1, 2014
  6. Mike StumpAug 1, 2014
  7. Philip OakleyAug 2, 2014
  8. Philip OakleyAug 2, 2014
  9. Sam VilainAug 1, 2014
  10. Mike StumpAug 1, 2014
  11. Nico WilliamsAug 1, 2014
  12. Alex DavidsonAug 2, 2014
  13. Mike StumpAug 6, 2014
  14. Rebase safely (Re: cherry picking and merge)Nico Williams, Aug 6, 2014
  15. Nico WilliamsAug 6, 2014
  16. Mike StumpAug 1, 2014
  17. Keller, Jacob EAug 21, 2014
  18. Keller, Jacob EAug 21, 2014
  19. Nico WilliamsAug 1, 2014
  20. Mike StumpAug 1, 2014
  21. Nico WilliamsAug 1, 2014
  22. Jonathan NiederAug 1, 2014
  23. Jonathan NiederAug 1, 2014
  24. Nico WilliamsAug 1, 2014
  25. Junio C HamanoAug 1, 2014
  26. Nico WilliamsAug 1, 2014
  27. Junio C HamanoAug 1, 2014
  28. Jakub NarębskiAug 6, 2014
  29. Nico WilliamsAug 6, 2014
  30. Junio C HamanoAug 6, 2014
  31. Junio C HamanoAug 6, 2014
  32. Mike StumpAug 1, 2014
  33. Mike StumpAug 1, 2014
  34. Jonathan NiederAug 1, 2014
  35. Fwd: cherry picking and mergeJakub Narębski, Aug 1, 2014
  36. Mike StumpAug 1, 2014
  37. Philip OakleyAug 2, 2014
  38. Jakub NarębskiAug 6, 2014
  39. Mike StumpAug 6, 2014
  40. Nico WilliamsAug 7, 2014
  41. Mike StumpAug 8, 2014
  42. Nico WilliamsAug 8, 2014
  43. Fwd: Rebase safely (Re: cherry picking and merge)Mike Stump, Aug 8, 2014

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.