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

Re: multiple-commit cherry-pick?

From
Björn Steinbrink <b.steinbrink@gmx.de>
Date
Nov 6, 2008, 09:51 UTC
Message-ID
<20081106095122.GA2656@atjola.homenet>
In-Reply-To
<20081106032437.GA27237@euler>
On 2008.11.05 22:24:37 -0500, Deskin Miller wrote:
Show 17 quoted lines
> On Thu, Nov 06, 2008 at 11:45:27AM +0900, Miles Bader wrote:
> > Is there any easy way to cherry pick a _range_ of commits from some other
> > branch to the current branch, instead of just one?
> > 
> > I thought maybe git-rebase could be coerced to do this somehow, but I
> > couldn't figure a way.
> 
> Rebase is exactly what you want.  Given something like this:
> 
> o--o--o--A--B--C--o--o--X
>     \
>      o--o--D
> 
> where you want A, B, C to go on top of D:
> 
> $ git checkout -b newbranch C
> $ git rebase --onto D ^A
That should be A^ ;-)
> newbranch will have <...> --D--A--B--C

... and then you can merge newbranch into the existing branch that references D, fast-forwarding the branch. And then newbranch can be deleted.

If you don't want to use a temporary branch, you can also do (while on the branch onto which you want to cherry-pick):

git reset --hard C git rebase --onto ORIG_HEAD A^

Which should get you the same result, without using a temporary branch.
Björn
Previous: Deskin MillerNext: Miles Bader
Message 3 of 31 in “multiple-commit cherry-pick?”
  1. Miles BaderNov 6, 2008
  2. Deskin MillerNov 6, 2008
  3. Björn SteinbrinkNov 6, 2008
  4. Miles BaderNov 6, 2008
  5. Björn SteinbrinkNov 6, 2008
  6. Miles BaderNov 7, 2008
  7. Björn SteinbrinkNov 7, 2008
  8. Miles BaderNov 7, 2008
  9. Alex RiesenNov 6, 2008
  10. Linus TorvaldsNov 7, 2008
  11. Miles BaderNov 7, 2008
  12. Alex RiesenNov 7, 2008
  13. Junio C HamanoNov 7, 2008
  14. Alex RiesenNov 7, 2008
  15. Linus TorvaldsNov 7, 2008
  16. Alex RiesenNov 9, 2008
  17. Johannes SchindelinNov 10, 2008
  18. Alex RiesenNov 10, 2008
  19. Johannes SchindelinNov 10, 2008
  20. Chris FreyNov 14, 2008
  21. Johannes SchindelinNov 14, 2008
  22. Linus TorvaldsNov 14, 2008
  23. Johannes SchindelinNov 14, 2008
  24. Junio C HamanoNov 14, 2008
  25. Linus TorvaldsNov 14, 2008
  26. Linus TorvaldsNov 14, 2008
  27. Pierre HabouzitNov 16, 2008
  28. Francis GaliegueNov 14, 2008
  29. Junio C HamanoNov 10, 2008
  30. Johannes SchindelinNov 10, 2008
  31. Michael RadziejNov 7, 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.