{"thread":{"id":"24141","subject":"rebasing a merge","startedAt":"2010-06-17T15:51:03Z","lastAt":"2010-06-24T14:22:38Z","messageCount":6,"participants":["Jay Soffian","Peter Krefting"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"143874","messageId":"AANLkTilY_9j2sXlplhYB4FPAIAzuPBg2UyUTEk4DaaYF@mail.gmail.com","threadId":"24141","inReplyTo":null,"subject":"rebasing a merge","fromName":"Jay Soffian","fromEmail":"jaysoffian@gmail.com","sentAt":"2010-06-17T15:51:03Z","receivedAt":"2010-06-17T15:51:03Z","isPatch":false,"sender":{"key":"jaysoffian@gmail.com","avatar":"https://avatars.githubusercontent.com/u/155970?v=4"},"body":"Say you have:\n\n-o--o--o--m master\n         /\n--o--o--o   side\n\nYou're ready to push the merge, but in the mean time:\n\n         o--o--o origin/master\n        /\n-o--o--o--m master\n         /\n--o--o--o   side\n\nFor various reasons, when this happens I want to rebase my merge (m).\nIt is almost always a merge that involves a fair amount of conflict\nresolution. Here's how I've been doing it, but I'll bet there's a less\nconvoluted way:\n\ngit merge origin/master                      # resolve as needed\ngit branch -f temp                           # save the tree\ngit reset --hard ORIG_HEAD                   # restore back to the merge\ngit rebase -i -p --onto origin/master HEAD~1 # rebase the merge\ngit checkout temp -- .                       # resolve the conflict here\ngit rebase --continue                        # commit the resolution\ngit diff temp                                # no differences\ngit branch -D temp\n\nThoughts?\n\nj.\n"},{"id":"143894","messageId":"AANLkTimyqTOhkeDIMLwgw3iuN0IkDDquPi1tMV5WKoNc@mail.gmail.com","threadId":"24141","inReplyTo":"AANLkTilY_9j2sXlplhYB4FPAIAzuPBg2UyUTEk4DaaYF@mail.gmail.com","subject":"Re: rebasing a merge","fromName":"Jay Soffian","fromEmail":"jaysoffian@gmail.com","sentAt":"2010-06-18T04:38:16Z","receivedAt":"2010-06-18T04:38:16Z","isPatch":false,"sender":{"key":"jaysoffian@gmail.com","avatar":"https://avatars.githubusercontent.com/u/155970?v=4"},"body":"On Thu, Jun 17, 2010 at 11:51 AM, Jay Soffian <jaysoffian@gmail.com> wrote:\n> git merge origin/master                      # resolve as needed\n> git branch -f temp                           # save the tree\n> git reset --hard ORIG_HEAD                   # restore back to the merge\n> git rebase -i -p --onto origin/master HEAD~1 # rebase the merge\n> git checkout temp -- .                       # resolve the conflict here\n> git rebase --continue                        # commit the resolution\n> git diff temp                                # no differences\n> git branch -D temp\n\nThis is a bit more efficient:\n\nmc=$(git rev-parse HEAD)\np1=$(git rev-parse origin)\np2=$(git rev-parse HEAD^2)\ngit merge origin || exit 0\ntree=$(git log -1 HEAD --pretty=%T)\ngit reset --hard $(git cat-file commit $mc | sed '1,/^$/d' | git\ncommit-tree $tree -p $p1 -p $p2)\n"},{"id":"143897","messageId":"alpine.DEB.2.00.1006181010220.12445@ds9.cixit.se","threadId":"24141","inReplyTo":"AANLkTilY_9j2sXlplhYB4FPAIAzuPBg2UyUTEk4DaaYF@mail.gmail.com","subject":"Re: rebasing a merge","fromName":"Peter Krefting","fromEmail":"peter@softwolves.pp.se","sentAt":"2010-06-18T09:10:58Z","receivedAt":"2010-06-18T09:10:58Z","isPatch":false,"sender":{"key":"peter@softwolves.pp.se","avatar":"https://avatars.githubusercontent.com/u/990764?v=4"},"body":"Jay Soffian:\n\n> Here's how I've been doing it, but I'll bet there's a less convoluted way:\n\nDo you have git-rerere enabled? I have found that to be a major timesaver \nfor cases like these.\n\n-- \n\\\\// Peter - http://www.softwolves.pp.se/\n"},{"id":"143908","messageId":"AANLkTikH9S1GCOwJfmKvO4fTvG46libJtrdMNQeiBm1_@mail.gmail.com","threadId":"24141","inReplyTo":"alpine.DEB.2.00.1006181010220.12445@ds9.cixit.se","subject":"Re: rebasing a merge","fromName":"Jay Soffian","fromEmail":"jaysoffian@gmail.com","sentAt":"2010-06-18T15:19:14Z","receivedAt":"2010-06-18T15:19:14Z","isPatch":false,"sender":{"key":"jaysoffian@gmail.com","avatar":"https://avatars.githubusercontent.com/u/155970?v=4"},"body":"On Fri, Jun 18, 2010 at 5:10 AM, Peter Krefting <peter@softwolves.pp.se> wrote:\n> Jay Soffian:\n>\n>> Here's how I've been doing it, but I'll bet there's a less convoluted way:\n>\n> Do you have git-rerere enabled? I have found that to be a major timesaver\n> for cases like these.\n\nI'm familiar with rerere. The problem is that my original merge often\ntakes me several attempts to get correct, where each attempt I'm\namending the merge. So once the merge is finally correct, I need to\nretrain rerere (see my earlier post to the list about this). Now at\nthat point, I could use \"git rebase  -i -p --onto ...\" to redo the\nmerge and let rerere take care of the conflict resolution.\n\nWhich is what I was doing. But it occurred to me that the final tree\nthat I want is the same as if I just do a second merge, save that off,\nthen redo my original merge and commit it with the second merge's\ntree. This is also a lot faster (this repo is 1GB well packed composed\nof 40k files) and I think less error prone.\n\nj.\n"},{"id":"144125","messageId":"alpine.DEB.2.00.1006241012400.28950@ds9.cixit.se","threadId":"24141","inReplyTo":"AANLkTikH9S1GCOwJfmKvO4fTvG46libJtrdMNQeiBm1_@mail.gmail.com","subject":"Re: rebasing a merge","fromName":"Peter Krefting","fromEmail":"peter@softwolves.pp.se","sentAt":"2010-06-24T09:16:19Z","receivedAt":"2010-06-24T09:16:19Z","isPatch":false,"sender":{"key":"peter@softwolves.pp.se","avatar":"https://avatars.githubusercontent.com/u/990764?v=4"},"body":"Jay Soffian:\n\n> I'm familiar with rerere.\n\nYes, of course, sorry for not recognizing your name :-)\n\n> Which is what I was doing. But it occurred to me that the final tree\n> that I want is the same as if I just do a second merge,\n\nSo, you want to just discard the change in the new commit on the branch you \nmerged?\n\nYou could probably get off by \"git cat-file\" the commit object, changing the \nparent reference to point to the newly introduced commit while leaving the \nrest intact, and then \"git hash-object\" the new commit object, and then \nforward the branch head to that one.\n\n-- \n\\\\// Peter - http://www.softwolves.pp.se/\n"},{"id":"144154","messageId":"AANLkTik5PteeUzGvElMTiTiFf64s4KFEyoTAq_f8wLAf@mail.gmail.com","threadId":"24141","inReplyTo":"alpine.DEB.2.00.1006241012400.28950@ds9.cixit.se","subject":"Re: rebasing a merge","fromName":"Jay Soffian","fromEmail":"jaysoffian@gmail.com","sentAt":"2010-06-24T14:22:38Z","receivedAt":"2010-06-24T14:22:38Z","isPatch":false,"sender":{"key":"jaysoffian@gmail.com","avatar":"https://avatars.githubusercontent.com/u/155970?v=4"},"body":"On Thu, Jun 24, 2010 at 5:16 AM, Peter Krefting <peter@softwolves.pp.se> wrote:\n> You could probably get off by \"git cat-file\" the commit object, changing the\n> parent reference to point to the newly introduced commit while leaving the\n> rest intact, and then \"git hash-object\" the new commit object, and then\n> forward the branch head to that one.\n\nDid you miss my followup message?\n\nhttp://article.gmane.org/gmane.comp.version-control.git/149335\n\nj.\n"}]}