{"thread":{"id":"18705","subject":"How to merge in different order?","startedAt":"2009-04-03T16:12:08Z","lastAt":"2009-04-03T17:59:24Z","messageCount":4,"participants":["Josef Wolf","Peter Harris","Jeff King"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"110292","messageId":"20090403161208.GC28619@raven.wolf.lan","threadId":"18705","inReplyTo":null,"subject":"How to merge in different order?","fromName":"Josef Wolf","fromEmail":"jw@raven.inka.de","sentAt":"2009-04-03T16:12:08Z","receivedAt":"2009-04-03T16:12:08Z","isPatch":false,"sender":{"key":"jw@raven.inka.de","avatar":null},"body":"Hello,\n\nGiven a branch that looks like\n\n  A1  A2  A3  A4  A5\n\nI would like to merge into another branch in the order\n\n  A1  A3  A4  A2  A5\n\nWhen I merge A3, then A2 is merged also.  git-merge don't seem\nto have an option to omit slurping older commits?\n"},{"id":"110295","messageId":"eaa105840904030930j7d576a61s25677c0dd5d16767@mail.gmail.com","threadId":"18705","inReplyTo":"20090403161208.GC28619@raven.wolf.lan","subject":"Re: How to merge in different order?","fromName":"Peter Harris","fromEmail":"git@peter.is-a-geek.org","sentAt":"2009-04-03T16:30:46Z","receivedAt":"2009-04-03T16:30:46Z","isPatch":false,"sender":{"key":"git@peter.is-a-geek.org","avatar":null},"body":"On Fri, Apr 3, 2009 at 12:12 PM, Josef Wolf wrote:\n> Hello,\n>\n> Given a branch that looks like\n>\n>  A1  A2  A3  A4  A5\n>\n> I would like to merge into another branch in the order\n>\n>  A1  A3  A4  A2  A5\n>\n> When I merge A3, then A2 is merged also.  git-merge don't seem\n> to have an option to omit slurping older commits?\n\n\"git merge\" merges the entire branch. It sounds like you are looking\nfor \"git cherry-pick\" instead.\n\nAlternatively, you could run \"git rebase -i A1\" on the branch before\nmerging it. (See the docs for details)\n\nPeter Harris\n"},{"id":"110296","messageId":"20090403163150.GD8155@coredump.intra.peff.net","threadId":"18705","inReplyTo":"20090403161208.GC28619@raven.wolf.lan","subject":"Re: How to merge in different order?","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2009-04-03T16:31:50Z","receivedAt":"2009-04-03T16:31:50Z","isPatch":false,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Fri, Apr 03, 2009 at 06:12:08PM +0200, Josef Wolf wrote:\n\n> Given a branch that looks like\n> \n>   A1  A2  A3  A4  A5\n> \n> I would like to merge into another branch in the order\n> \n>   A1  A3  A4  A2  A5\n> \n> When I merge A3, then A2 is merged also.  git-merge don't seem\n> to have an option to omit slurping older commits?\n\nRight. Remember that git represents history as a directed graph, so a\nmerge is really just another commit saying \"I include all history\nleading up to these two commits\". There is no way to say \"I include the\nhistory leading up to these commits, minus some other commits\".\n\nIf you just want to throw away A2, you can \"git revert\" it, then merge.\n\nBut what you probably want to do is rewrite the history of your branch\nto re-order the commits. You can do this with \"git rebase -i\". Like any\nhistory rewriting, this can cause difficulties for people who you have\nalready shared the branch with (because it will replace the commits that\nthey already have with 5 _new_ commits that just happen to do more or\nless the same thing).\n\nIf you have already shared the branch, you may just want to cherry-pick\nthe changes you want (using \"git cherry-pick\") onto your other branch.\n\n-Peff\n"},{"id":"110299","messageId":"20090403175924.GD28619@raven.wolf.lan","threadId":"18705","inReplyTo":"20090403163150.GD8155@coredump.intra.peff.net","subject":"Re: How to merge in different order?","fromName":"Josef Wolf","fromEmail":"jw@raven.inka.de","sentAt":"2009-04-03T17:59:24Z","receivedAt":"2009-04-03T17:59:24Z","isPatch":false,"sender":{"key":"jw@raven.inka.de","avatar":null},"body":"On Fri, Apr 03, 2009 at 12:31:50PM -0400, Jeff King wrote:\n\n[ ... ]\n> But what you probably want to do is rewrite the history of your branch\n> to re-order the commits.\n\nYeah, That's exactly what I need. But I guess there's a lot of work ahead:\nabout 2500 commits are waiting for the sort.\n\n> You can do this with \"git rebase -i\".\n\nSounds good\n\n> Like any\n> history rewriting, this can cause difficulties for people who you have\n> already shared the branch with (because it will replace the commits that\n> they already have with 5 _new_ commits that just happen to do more or\n> less the same thing).\n\nThis is a copy of a svn repository, created with git-svn. So the branch\nis shared with other people.\n\n> If you have already shared the branch, you may just want to cherry-pick\n> the changes you want (using \"git cherry-pick\") onto your other branch.\n\nArgh, I was looking for git-cherry, but that does something different ;-)\n\nThanks for the answer, Jeff!\n"}]}