{"thread":{"id":"20168","subject":"how to reorder commits","startedAt":"2009-07-20T15:07:50Z","lastAt":"2009-07-21T07:53:48Z","messageCount":6,"participants":["Rustom Mody","Santi Béjar","Daniel Barkalow"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"118319","messageId":"f46c52560907200807heed4bbfkde15cccd2ae8151d@mail.gmail.com","threadId":"20168","inReplyTo":null,"subject":"how to reorder commits","fromName":"Rustom Mody","fromEmail":"rustompmody@gmail.com","sentAt":"2009-07-20T15:07:50Z","receivedAt":"2009-07-20T15:07:50Z","isPatch":false,"sender":{"key":"rustompmody@gmail.com","avatar":null},"body":"I have a sequence of commits. I tried to reorder the top two in this way.\n$ git rebase -i HEAD^^\n\nflip the two pick lines and exit vi\n\nI find my file full of conflict markers.\nSo what is the way of doing:\nHEAD becomes current HEAD^\nHEAD^ becomes current HEAD\nwithout having to handle conflicts ??\n"},{"id":"118328","messageId":"adf1fd3d0907200837k63f21504v3d660f9503962fcf@mail.gmail.com","threadId":"20168","inReplyTo":"f46c52560907200807heed4bbfkde15cccd2ae8151d@mail.gmail.com","subject":"Re: how to reorder commits","fromName":"Santi Béjar","fromEmail":"santi@agolina.net","sentAt":"2009-07-20T15:37:47Z","receivedAt":"2009-07-20T15:37:47Z","isPatch":false,"sender":{"key":"santi@agolina.net","avatar":null},"body":"2009/7/20 Rustom Mody <rustompmody@gmail.com>:\n> I have a sequence of commits. I tried to reorder the top two in this way.\n> $ git rebase -i HEAD^^\n>\n> flip the two pick lines and exit vi\n>\n> I find my file full of conflict markers.\n\n\"git rebase\" applies the changes between the commit and the parent,\nand if the changes have conflicts this is what you get.\n\n> So what is the way of doing:\n> HEAD becomes current HEAD^\n> HEAD^ becomes current HEAD\n\n$ git branch old\n$ git reset --hard HEAD~2\n$ git read-tree old\n$ git commit -C old\n$ git read-tree old^\n$ git commit -C old^\n\nBut normally you reorder \"changes\", not trees.\n\nHTH,\nSanti\n"},{"id":"118329","messageId":"f46c52560907200901w67edbbdcpe405f28d98953354@mail.gmail.com","threadId":"20168","inReplyTo":"adf1fd3d0907200837k63f21504v3d660f9503962fcf@mail.gmail.com","subject":"Re: how to reorder commits","fromName":"Rustom Mody","fromEmail":"rustompmody@gmail.com","sentAt":"2009-07-20T16:01:34Z","receivedAt":"2009-07-20T16:01:34Z","isPatch":false,"sender":{"key":"rustompmody@gmail.com","avatar":null},"body":"On Mon, Jul 20, 2009 at 9:07 PM, Santi Béjar<santi@agolina.net> wrote:\n> 2009/7/20 Rustom Mody <rustompmody@gmail.com>:\n>> I have a sequence of commits. I tried to reorder the top two in this way.\n>> $ git rebase -i HEAD^^\n>>\n>> flip the two pick lines and exit vi\n>>\n>> I find my file full of conflict markers.\n>\n> \"git rebase\" applies the changes between the commit and the parent,\n> and if the changes have conflicts this is what you get.\n>\n>> So what is the way of doing:\n>> HEAD becomes current HEAD^\n>> HEAD^ becomes current HEAD\n>\n> $ git branch old\n> $ git reset --hard HEAD~2\n> $ git read-tree old\n> $ git commit -C old\n> $ git read-tree old^\n> $ git commit -C old^\n\nBeautiful -- plumbing is nifty!\n\n>\n> But normally you reorder \"changes\", not trees.\n\nWhich may not always be conflict-free?\n"},{"id":"118330","messageId":"adf1fd3d0907200916x752cba3cw901965788acae0c5@mail.gmail.com","threadId":"20168","inReplyTo":"f46c52560907200901w67edbbdcpe405f28d98953354@mail.gmail.com","subject":"Re: how to reorder commits","fromName":"Santi Béjar","fromEmail":"santi@agolina.net","sentAt":"2009-07-20T16:16:08Z","receivedAt":"2009-07-20T16:16:08Z","isPatch":false,"sender":{"key":"santi@agolina.net","avatar":null},"body":"2009/7/20 Rustom Mody <rustompmody@gmail.com>:\n> On Mon, Jul 20, 2009 at 9:07 PM, Santi Béjar<santi@agolina.net> wrote:\n>> But normally you reorder \"changes\", not trees.\n>\n> Which may not always be conflict-free?\n\nNo. But the fact that there is no porcelain way to do it may show that\nreordering trees is not what you normally want, even if reordering\ntrees is conflict-free.\n\nHTH,\nSanti\n"},{"id":"118347","messageId":"alpine.LNX.2.00.0907201717570.2147@iabervon.org","threadId":"20168","inReplyTo":"f46c52560907200807heed4bbfkde15cccd2ae8151d@mail.gmail.com","subject":"Re: how to reorder commits","fromName":"Daniel Barkalow","fromEmail":"barkalow@iabervon.org","sentAt":"2009-07-20T21:27:25Z","receivedAt":"2009-07-20T21:27:25Z","isPatch":false,"sender":{"key":"barkalow@iabervon.org","avatar":"https://avatars.githubusercontent.com/u/55364219?v=4"},"body":"On Mon, 20 Jul 2009, Rustom Mody wrote:\n\n> I have a sequence of commits. I tried to reorder the top two in this way.\n> $ git rebase -i HEAD^^\n> \n> flip the two pick lines and exit vi\n> \n> I find my file full of conflict markers.\n> So what is the way of doing:\n> HEAD becomes current HEAD^\n> HEAD^ becomes current HEAD\n> without having to handle conflicts ??\n\nNote that what you're asking for here would add both changes in HEAD^ and \n*remove* some changes in HEAD (to get to the state where only the change \nthat was made first has been made).\n\nWhat you tried with rebase is correct, but if your changes in those \ncommits intersect, impossible to do automatically:\n\nOriginal:\n\n This is an example.\n\nChange 1:\n\n-This is an example.\n+This is a better example.\n\nChange 2:\n\n-This is a better example.\n+This is a better sentence.\n\nNow, make change 2 without change 1. Even if you can split the changes as\n(1) \"an\"->\"a better\"; (2) \"example\"->\"sentence\", you get:\n\n This is an sentence.\n\nWhen the correct version would be:\n\n This is a sentence.\n\nBut there's no automated way to know this, so you get conflict markers.\n\n\t-Daniel\n*This .sig left intentionally blank*\n"},{"id":"118357","messageId":"f46c52560907210053k53c092c6t3268231ed08153d3@mail.gmail.com","threadId":"20168","inReplyTo":"873a8r132o.fsf@krank.kagedal.org","subject":"Re: how to reorder commits","fromName":"Rustom Mody","fromEmail":"rustompmody@gmail.com","sentAt":"2009-07-21T07:53:48Z","receivedAt":"2009-07-21T07:53:48Z","isPatch":false,"sender":{"key":"rustompmody@gmail.com","avatar":null},"body":"On Tue, Jul 21, 2009 at 2:31 AM, David Kågedal<david@kagedal.org> wrote:\n>\n> Latest stgit actually has it. You can push a patch with the --set-tree\n> flag. So your sequence of commands would have been (with the latest\n> two commits as stg patches called \"old\" and \"older\")\n>\n> $ stg series\n... example snipped ...\n\nThanks for the info but I gather that stgit does not run on windows?\nI need git to run on both on linux and windows.\n"}]}