{"thread":{"id":"3281","subject":"How to pull a single changeset from a child branch into a parent branch?","startedAt":"2006-02-10T04:03:54Z","lastAt":"2006-02-10T21:16:21Z","messageCount":3,"participants":["Ben Greear","Junio C Hamano"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"15839","messageId":"43EC10AA.1040800@candelatech.com","threadId":"3281","inReplyTo":null,"subject":"How to pull a single changeset from a child branch into a parent branch?","fromName":"Ben Greear","fromEmail":"greearb@candelatech.com","sentAt":"2006-02-10T04:03:54Z","receivedAt":"2006-02-10T04:03:54Z","isPatch":false,"sender":{"key":"greearb@candelatech.com","avatar":null},"body":"I have a linux-2.6 repo with two branches off of 2.6.13.\n\nOne branch (ben_v13) has just my own changes.\nA second branch (work_v13) has the 2.6.13.5 patch, and I've also pulled\nben_v13 into it.\n\nNow, I made a small change to work_v13, and I'd like to pull only\nthat changeset into ben_v13.  Is there a way to do that w/out\nhaving to export and apply a patch?\n\nThanks,\nBen\n\n-- \nBen Greear <greearb@candelatech.com>\nCandela Technologies Inc  http://www.candelatech.com\n"},{"id":"15843","messageId":"7vzmkzyfhh.fsf@assigned-by-dhcp.cox.net","threadId":"3281","inReplyTo":"43EC10AA.1040800@candelatech.com","subject":"Re: How to pull a single changeset from a child branch into a parent branch?","fromName":"Junio C Hamano","fromEmail":"junkio@cox.net","sentAt":"2006-02-10T05:01:14Z","receivedAt":"2006-02-10T05:01:14Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Ben Greear <greearb@candelatech.com> writes:\n\n> I have a linux-2.6 repo with two branches off of 2.6.13.\n>\n> One branch (ben_v13) has just my own changes.\n> A second branch (work_v13) has the 2.6.13.5 patch, and I've also pulled\n> ben_v13 into it.\n\n                     \"2.6.13.5\"\n         o---o---o---o\n        /             \\ \"work_v13\"\n    ---o \"2.6.13\"  .---*\n        \\         /\n         o---o---o\n                 \"ben_v13\"\n\n\t'o' are commits, '*' is a merge.\n\n> Now, I made a small change to work_v13,\n\n                     \"2.6.13.5\"\n         o---o---o---o\n        /             \\   \"work_v13\"\n    ---o \"2.6.13\"  .---*---x\n        \\         /        (new change)\n         o---o---o\n                 \"ben_v13\"\n\n> ... and I'd like to pull only\n> that changeset into ben_v13.  Is there a way to do that w/out\n> having to export and apply a patch?\n\nI would have done things differently.\n\nIt is generally a good idea if a change is applicable to more\nthan one branches, and these branches have merge relationship\nbetween them (work_v13 merges from ben_v13, which has already\nhappened), then to apply that change to the oldest branch and\npull the branch to the new one.  In other words, if you made the\nchange to 2.6.13 based one, you could have pulled that into\n2.6.13.5 based one.\n\n                     \"2.6.13.5\"\n         o---o---o---o\n        /             \\   \"work_v13\"\n    ---o \"2.6.13\"  .---*\n        \\         /\n         o---o---o---x\n                      \"ben_v13\"\n                   (new change)\n\n    [Commit what is applicable to both in older branch]\n\n                     \"2.6.13.5\"\n         o---o---o---o\n        /             \\   \"work_v13\"\n    ---o \"2.6.13\"  .---*--*\n        \\         /      /\n         o---o---o---x---'\n                      \"ben_v13\" \n                   (new change)\n\n    [And then merge that to the derived one]\n\n\nAssuming that correcting the situation like this is not an\noption, you could check \"git cherry-pick\".  It lets you create\nsomething like this:\n\n                     \"2.6.13.5\"\n         o---o---o---o\n        /             \\   \"work_v13\"\n    ---o \"2.6.13\"  .---*---x\n        \\         /\n         o---o---o---------x'\n                 \"ben_v13\" (equivalent of 'x' commit)\n\n\nThe command sequence to do this is:\n\n\t$ git checkout ben_v13\n        $ git cherry-pick work_v13\n"},{"id":"15862","messageId":"43ED02A5.6030500@candelatech.com","threadId":"3281","inReplyTo":"7vzmkzyfhh.fsf@assigned-by-dhcp.cox.net","subject":"Re: How to pull a single changeset from a child branch into a parent branch?","fromName":"Ben Greear","fromEmail":"greearb@candelatech.com","sentAt":"2006-02-10T21:16:21Z","receivedAt":"2006-02-10T21:16:21Z","isPatch":false,"sender":{"key":"greearb@candelatech.com","avatar":null},"body":"Junio C Hamano wrote:\n> Ben Greear <greearb@candelatech.com> writes:\n> \n> \n>>I have a linux-2.6 repo with two branches off of 2.6.13.\n>>\n>>One branch (ben_v13) has just my own changes.\n>>A second branch (work_v13) has the 2.6.13.5 patch, and I've also pulled\n>>ben_v13 into it.\n> \n> \n>                      \"2.6.13.5\"\n>          o---o---o---o\n>         /             \\ \"work_v13\"\n>     ---o \"2.6.13\"  .---*\n>         \\         /\n>          o---o---o\n>                  \"ben_v13\"\n> \n> \t'o' are commits, '*' is a merge.\n> \n> \n>>Now, I made a small change to work_v13,\n> \n> \n>                      \"2.6.13.5\"\n>          o---o---o---o\n>         /             \\   \"work_v13\"\n>     ---o \"2.6.13\"  .---*---x\n>         \\         /        (new change)\n>          o---o---o\n>                  \"ben_v13\"\n> \n> \n>>... and I'd like to pull only\n>>that changeset into ben_v13.  Is there a way to do that w/out\n>>having to export and apply a patch?\n> \n> \n> I would have done things differently.\n\nYeah, the main problem is that I test in the combined tree\nand forgot to change to the ben_v13 tree before making\nmy changes...\n\nI'll try out the cherry-pick option..and if that doesn't\nwork, I'll just manually patch the changes into the ben_v13\ntree.\n\nThanks,\nBen\n\n\n-- \nBen Greear <greearb@candelatech.com>\nCandela Technologies Inc  http://www.candelatech.com\n"}]}