{"thread":{"id":"27673","subject":"Preserve merge changes with rebase -p","startedAt":"2011-06-21T12:11:25Z","lastAt":"2011-06-21T15:07:49Z","messageCount":3,"participants":["Matteo Cypriani","Andrew Wong"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"170366","messageId":"201106211411.31739.mcy@lm7.fr","threadId":"27673","inReplyTo":null,"subject":"Preserve merge changes with rebase -p","fromName":"Matteo Cypriani","fromEmail":"mcy@lm7.fr","sentAt":"2011-06-21T12:11:25Z","receivedAt":"2011-06-21T12:11:25Z","isPatch":false,"sender":{"key":"mcy@lm7.fr","avatar":null},"body":"Hi all,\n\nI needed to change the author of a commit that was before a merge in the \nhistory. Here is a figure of my situation, E being the commit I want to edit, \nand M the problematic merge commit:\n\n     o---o---o---o---o---o---o---o  master\n              \\       \\ \n               o---E---M---o---o  topic\n\n\nIn a simple case, git rebase -i -p from topic does the trick here, I can amend \nE and M is re-created correctly.\n\nThe thing is, my M was not a \"simple merge commit\", but contained some changes \nneeded for the code in master and topic to work together. In that case, git \nrebase -i -p recreates a merge commit, but it does not keep the changes \nintroduced in M.\n\nIs there any way to keep the M's changes in my case (except to manually patch \n& amend the re-created merge commit) ?\nIf not, maybe it would be a nice functionnality to implement ?\n\nCheers,\n  Matteo\n\nP.S.: Please CC me if you answer to this e-mail, as I'm not subscribed to the \nlist.\n\n-- \nMa clef GPG est disponible sur keyserver.veridis.com\nMy GPG key is available on keyserver.veridis.com\n"},{"id":"170387","messageId":"4E00AE60.5000801@sohovfx.com","threadId":"27673","inReplyTo":"201106211411.31739.mcy@lm7.fr","subject":"Re: Preserve merge changes with rebase -p","fromName":"Andrew Wong","fromEmail":"andrew.w@sohovfx.com","sentAt":"2011-06-21T14:44:48Z","receivedAt":"2011-06-21T14:44:48Z","isPatch":false,"sender":{"key":"andrew.w@sohovfx.com","avatar":null},"body":"On 06/21/2011 08:11 AM, Matteo Cypriani wrote:\n> The thing is, my M was not a \"simple merge commit\", but contained some changes \n> needed for the code in master and topic to work together. In that case, git \n> rebase -i -p recreates a merge commit, but it does not keep the changes \n> introduced in M.\n>\n> Is there any way to keep the M's changes in my case (except to manually patch \n> & amend the re-created merge commit) ?\n>   \nUnfortunately, I don't think there's any nice way to do it right now. I\nthink what you could do for now is make the \"pick <M>\" into a \"edit\n<M>\", together with other changes you want to make. And then when you\nget to \"edit M\", do a \"git cherry-pick -n -m 1 <M>\", or \"-m 2\" depending\non how your merge was done. That should bring your changes over. Then\nyou just need resolve and add any conflicts, and do a \"rebase --continue\".\n\nI've only tried it on a simple case and that seems to work.\n\n> If not, maybe it would be a nice functionnality to implement ?\n>   \nI imagine this is pretty useful feature to have too. I could look into\nadding this support when I got a chance. I haven't given it much thought\nyet though, so I don't know how feasible it is.\n"},{"id":"170389","messageId":"201106211707.53486.mcy@lm7.fr","threadId":"27673","inReplyTo":"4E00AE60.5000801@sohovfx.com","subject":"Re: Preserve merge changes with rebase -p","fromName":"Matteo Cypriani","fromEmail":"mcy@lm7.fr","sentAt":"2011-06-21T15:07:49Z","receivedAt":"2011-06-21T15:07:49Z","isPatch":false,"sender":{"key":"mcy@lm7.fr","avatar":null},"body":"Le mardi 21 juin 2011 16:44:48, Andrew Wong a écrit :\n> Unfortunately, I don't think there's any nice way to do it right now. I\n> think what you could do for now is make the \"pick <M>\" into a \"edit\n> <M>\", together with other changes you want to make. And then when you\n> get to \"edit M\", do a \"git cherry-pick -n -m 1 <M>\", or \"-m 2\" depending\n> on how your merge was done. That should bring your changes over. Then\n> you just need resolve and add any conflicts, and do a \"rebase --continue\".\n\nThank you, I'll try that the next time.\n\n\n> I imagine this is pretty useful feature to have too. I could look into\n> adding this support when I got a chance.\n\nThat would be great, many thanks in advance!\n\nCheers,\n\n  Matteo\n\n-- \nMa clef GPG est disponible sur keyserver.veridis.com\nMy GPG key is available on keyserver.veridis.com\n"}]}