{"thread":{"id":"34565","subject":"Flatten history","startedAt":"2013-07-30T01:42:14Z","lastAt":"2013-07-30T04:08:19Z","messageCount":5,"participants":["Hilco Wijbenga","Felipe Contreras","Bryan Turner"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"224275","messageId":"CAE1pOi0CQ1k3h3ie=s3qvkQog9foYBOnJ++uuum-Br7vzQHRSQ@mail.gmail.com","threadId":"34565","inReplyTo":null,"subject":"Flatten history","fromName":"Hilco Wijbenga","fromEmail":"hilco.wijbenga@gmail.com","sentAt":"2013-07-30T01:42:14Z","receivedAt":"2013-07-30T01:42:14Z","isPatch":false,"sender":{"key":"hilco.wijbenga@gmail.com","avatar":null},"body":"Hi all,\n\nI have a (public) \"feature\" branch that has been kept up-to-date with\n\"master\" by regularly merging master back into it. I would now like to\nget all the changes from feature but not any of the commits.\nBasically, I want to replay all of feature's commits without creating\nthose commits.\n\nI thought something like\n\ngit cherry-pick -n abcd^..feature\n\nshould do the trick (while on master, where abcd is the SHA-1 of the\ncommit where feature was created) but I get conflicts.\n\nFirst, why the conflicts? I have done all the merges so cherry-pick\nshould simply be able to replay them? Second, what is the correct way\nof doing this?\n\nCheers,\nHilco\n\nP.S. The most annoying thing is that I've done this exact thing before\nbut I can't find what command I used. :-)\n"},{"id":"224278","messageId":"CAMP44s2pXSN2HbpGLW9jrgJAypbLM3JtgD+nyK7LkNdvH4nsfQ@mail.gmail.com","threadId":"34565","inReplyTo":"CAE1pOi0CQ1k3h3ie=s3qvkQog9foYBOnJ++uuum-Br7vzQHRSQ@mail.gmail.com","subject":"Re: Flatten history","fromName":"Felipe Contreras","fromEmail":"felipe.contreras@gmail.com","sentAt":"2013-07-30T03:50:38Z","receivedAt":"2013-07-30T03:50:38Z","isPatch":false,"sender":{"key":"felipe.contreras@gmail.com","avatar":"https://avatars.githubusercontent.com/u/8358?v=4"},"body":"On Mon, Jul 29, 2013 at 8:42 PM, Hilco Wijbenga\n<hilco.wijbenga@gmail.com> wrote:\n> Hi all,\n>\n> I have a (public) \"feature\" branch that has been kept up-to-date with\n> \"master\" by regularly merging master back into it. I would now like to\n> get all the changes from feature but not any of the commits.\n> Basically, I want to replay all of feature's commits without creating\n> those commits.\n>\n> I thought something like\n>\n> git cherry-pick -n abcd^..feature\n>\n> should do the trick (while on master, where abcd is the SHA-1 of the\n> commit where feature was created) but I get conflicts.\n>\n> First, why the conflicts? I have done all the merges so cherry-pick\n> should simply be able to replay them? Second, what is the correct way\n> of doing this?\n\nPerhaps\n\n% git cherry-pick -n --no-merges --right-only --topo-order\n--cherry-pick abcd^..feature\n\n-- \nFelipe Contreras\n"},{"id":"224279","messageId":"CAGyf7-FXp-a+HmoRQBrUWu2xc-UvbsZUfZz7GTce2JzwrsfMVw@mail.gmail.com","threadId":"34565","inReplyTo":"CAMP44s2pXSN2HbpGLW9jrgJAypbLM3JtgD+nyK7LkNdvH4nsfQ@mail.gmail.com","subject":"Re: Flatten history","fromName":"Bryan Turner","fromEmail":"bturner@atlassian.com","sentAt":"2013-07-30T03:59:00Z","receivedAt":"2013-07-30T03:59:00Z","isPatch":false,"sender":{"key":"bturner@atlassian.com","avatar":"https://gravatar.com/avatar/16bcf3167981c1ef7c804e502642366d888a35b0d0b0a4ca01fdc442aa1acb1e?d=mp&s=160"},"body":"On 30 July 2013 13:50, Felipe Contreras <felipe.contreras@gmail.com> wrote:\n> On Mon, Jul 29, 2013 at 8:42 PM, Hilco Wijbenga\n> <hilco.wijbenga@gmail.com> wrote:\n>> Hi all,\n>>\n>> I have a (public) \"feature\" branch that has been kept up-to-date with\n>> \"master\" by regularly merging master back into it. I would now like to\n>> get all the changes from feature but not any of the commits.\n>> Basically, I want to replay all of feature's commits without creating\n>> those commits.\n>>\n>> I thought something like\n>>\n>> git cherry-pick -n abcd^..feature\n>>\n>> should do the trick (while on master, where abcd is the SHA-1 of the\n>> commit where feature was created) but I get conflicts.\n>>\n>> First, why the conflicts? I have done all the merges so cherry-pick\n>> should simply be able to replay them? Second, what is the correct way\n>> of doing this?\n>\n> Perhaps\n>\n> % git cherry-pick -n --no-merges --right-only --topo-order\n> --cherry-pick abcd^..feature\n>\n> --\n> Felipe Contreras\n\nWouldn't git merge --squash do what you're looking for? It seems like\nthe only way to not get conflicts trying to cherry pick is if you\nnever had any conflicts while you were merging master into your\nfeature branch. \"Evil\" merges, where you actually have to change code,\neven if it's just to resolve conflicts, don't tend to replay\ncorrectly.\n\nIt seems like this should do it:\n% git checkout master\nSwitched to branch 'master'\n% git merge --squash feature\nSquash commit -- not updating HEAD\nAutomatic merge went well; stopped before committing as requested\n% git commit\n\ngit merge --squash will just apply the changes without creating a\ncommit. You can then make any final changes you want to and write your\ncommit message for the feature.\n\nHope this helps,\nBryan Turner\n"},{"id":"224281","messageId":"CAE1pOi0LKy8hsjAEsFPPN+9mJRDoEE0a3sMv7gpnW8V95_W9sA@mail.gmail.com","threadId":"34565","inReplyTo":"CAMP44s2pXSN2HbpGLW9jrgJAypbLM3JtgD+nyK7LkNdvH4nsfQ@mail.gmail.com","subject":"Re: Flatten history","fromName":"Hilco Wijbenga","fromEmail":"hilco.wijbenga@gmail.com","sentAt":"2013-07-30T04:05:15Z","receivedAt":"2013-07-30T04:05:15Z","isPatch":false,"sender":{"key":"hilco.wijbenga@gmail.com","avatar":null},"body":"On 29 July 2013 20:50, Felipe Contreras <felipe.contreras@gmail.com> wrote:\n> On Mon, Jul 29, 2013 at 8:42 PM, Hilco Wijbenga\n> <hilco.wijbenga@gmail.com> wrote:\n>> Hi all,\n>>\n>> I have a (public) \"feature\" branch that has been kept up-to-date with\n>> \"master\" by regularly merging master back into it. I would now like to\n>> get all the changes from feature but not any of the commits.\n>> Basically, I want to replay all of feature's commits without creating\n>> those commits.\n>>\n>> I thought something like\n>>\n>> git cherry-pick -n abcd^..feature\n>>\n>> should do the trick (while on master, where abcd is the SHA-1 of the\n>> commit where feature was created) but I get conflicts.\n>>\n>> First, why the conflicts? I have done all the merges so cherry-pick\n>> should simply be able to replay them? Second, what is the correct way\n>> of doing this?\n>\n> Perhaps\n>\n> % git cherry-pick -n --no-merges --right-only --topo-order\n> --cherry-pick abcd^..feature\n\nThank you for the suggestion but this still gives me conflicts.\n"},{"id":"224282","messageId":"CAE1pOi0qQvPrG8te0kKVpPDx4LqSEuBHVw+-NRaxH1HT9CvqxA@mail.gmail.com","threadId":"34565","inReplyTo":"CAGyf7-FXp-a+HmoRQBrUWu2xc-UvbsZUfZz7GTce2JzwrsfMVw@mail.gmail.com","subject":"Re: Flatten history","fromName":"Hilco Wijbenga","fromEmail":"hilco.wijbenga@gmail.com","sentAt":"2013-07-30T04:08:19Z","receivedAt":"2013-07-30T04:08:19Z","isPatch":false,"sender":{"key":"hilco.wijbenga@gmail.com","avatar":null},"body":"On 29 July 2013 20:59, Bryan Turner <bturner@atlassian.com> wrote:\n> On 30 July 2013 13:50, Felipe Contreras <felipe.contreras@gmail.com> wrote:\n>> On Mon, Jul 29, 2013 at 8:42 PM, Hilco Wijbenga\n>> <hilco.wijbenga@gmail.com> wrote:\n>>> Hi all,\n>>>\n>>> I have a (public) \"feature\" branch that has been kept up-to-date with\n>>> \"master\" by regularly merging master back into it. I would now like to\n>>> get all the changes from feature but not any of the commits.\n>>> Basically, I want to replay all of feature's commits without creating\n>>> those commits.\n>>>\n>>> I thought something like\n>>>\n>>> git cherry-pick -n abcd^..feature\n>>>\n>>> should do the trick (while on master, where abcd is the SHA-1 of the\n>>> commit where feature was created) but I get conflicts.\n>>>\n>>> First, why the conflicts? I have done all the merges so cherry-pick\n>>> should simply be able to replay them? Second, what is the correct way\n>>> of doing this?\n>>\n>> Perhaps\n>>\n>> % git cherry-pick -n --no-merges --right-only --topo-order\n>> --cherry-pick abcd^..feature\n>>\n>> --\n>> Felipe Contreras\n>\n> Wouldn't git merge --squash do what you're looking for? It seems like\n> the only way to not get conflicts trying to cherry pick is if you\n> never had any conflicts while you were merging master into your\n> feature branch. \"Evil\" merges, where you actually have to change code,\n> even if it's just to resolve conflicts, don't tend to replay\n> correctly.\n>\n> It seems like this should do it:\n> % git checkout master\n> Switched to branch 'master'\n> % git merge --squash feature\n> Squash commit -- not updating HEAD\n> Automatic merge went well; stopped before committing as requested\n> % git commit\n>\n> git merge --squash will just apply the changes without creating a\n> commit. You can then make any final changes you want to and write your\n> commit message for the feature.\n\nAh, yes \"git merge --squash feature\" seems to do exactly what I was\nlooking for. Funny, I thought I did something with rev-list last time\nbut this --squash is much simpler. :-) Thank you!\n"}]}