{"thread":{"id":"36157","subject":"Apply commits from one branch to another branch (tree structure is different)","startedAt":"2014-03-14T17:39:31Z","lastAt":"2014-03-18T17:18:27Z","messageCount":9,"participants":["Jagan Teki","Andrew Wong","Brandon McCaig"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"236736","messageId":"CAD6G_RTZaaYBP0MrmRYhce2v+A+WwvY=97Do3LoWW-SYzkHM2g@mail.gmail.com","threadId":"36157","inReplyTo":null,"subject":"Apply commits from one branch to another branch (tree structure is different)","fromName":"Jagan Teki","fromEmail":"jagannadh.teki@gmail.com","sentAt":"2014-03-14T17:39:31Z","receivedAt":"2014-03-14T17:39:31Z","isPatch":false,"sender":{"key":"jagannadh.teki@gmail.com","avatar":null},"body":"Hi,\n\nI have two branch in one repo that I need to maintain for 2 different\ndeliveries.\nSay branch1 and branch2 in test.git repo.\n\ntest.git\n- branch1\n     foo_v1/text.txt\n     foo_v2/text.txt\n- branch2\n     foo/text.txt\n\nbranch1 is developers branch all source looks version'ed manner and\nbranch2 is superset for branch1, example foo_v1 and foo_v2 are the directories\nin branch1 where developer will update the latest one here foo_v2 and branch2\nfoo is same as the latest one of branch1 for an instance.\n\nSuppose developer send 10 patches on branch1 where are changes in terms\nof <dir>_<version>/ then I need to apply on my local repo branch1, till now\nis fine then I need to apply same 10 patches on to my branch2 where source\ntree <dir> which is quite question here how can I do.\n\nRequest for any help! let me know for any questions.\n\n\nthanks!\n-- \nJagan.\n"},{"id":"236737","messageId":"CAD6G_RSPNob11jzqyXiBR4zRuu3T00+qQ7rhNx_E4q+2-3h6iw@mail.gmail.com","threadId":"36157","inReplyTo":"CAD6G_RTZaaYBP0MrmRYhce2v+A+WwvY=97Do3LoWW-SYzkHM2g@mail.gmail.com","subject":"Re: Apply commits from one branch to another branch (tree structure is different)","fromName":"Jagan Teki","fromEmail":"jagannadh.teki@gmail.com","sentAt":"2014-03-14T18:11:49Z","receivedAt":"2014-03-14T18:11:49Z","isPatch":false,"sender":{"key":"jagannadh.teki@gmail.com","avatar":null},"body":"Don't know what happen, I'm unable to join #git channel\n[23:40] <Jagan> hi\n[23:40] == Cannot send to channel: #git\n\nCan any one help!\n\nOn Fri, Mar 14, 2014 at 11:09 PM, Jagan Teki <jagannadh.teki@gmail.com> wrote:\n> Hi,\n>\n> I have two branch in one repo that I need to maintain for 2 different\n> deliveries.\n> Say branch1 and branch2 in test.git repo.\n>\n> test.git\n> - branch1\n>      foo_v1/text.txt\n>      foo_v2/text.txt\n> - branch2\n>      foo/text.txt\n>\n> branch1 is developers branch all source looks version'ed manner and\n> branch2 is superset for branch1, example foo_v1 and foo_v2 are the directories\n> in branch1 where developer will update the latest one here foo_v2 and branch2\n> foo is same as the latest one of branch1 for an instance.\n>\n> Suppose developer send 10 patches on branch1 where are changes in terms\n> of <dir>_<version>/ then I need to apply on my local repo branch1, till now\n> is fine then I need to apply same 10 patches on to my branch2 where source\n> tree <dir> which is quite question here how can I do.\n>\n> Request for any help! let me know for any questions.\n>\n>\n> thanks!\n> --\n> Jagan.\n\n\n\n-- \nJagan.\n"},{"id":"236742","messageId":"CADeaMWpw4gx00QpUJ7u49sQvu7KbhvhH14TMdHXBRXq4wCNDZA@mail.gmail.com","threadId":"36157","inReplyTo":"CAD6G_RTZaaYBP0MrmRYhce2v+A+WwvY=97Do3LoWW-SYzkHM2g@mail.gmail.com","subject":"Re: Apply commits from one branch to another branch (tree structure is different)","fromName":"Andrew Wong","fromEmail":"andrew.kw.w@gmail.com","sentAt":"2014-03-14T19:18:47Z","receivedAt":"2014-03-14T19:18:47Z","isPatch":false,"sender":{"key":"andrew.kw.w@gmail.com","avatar":"https://avatars.githubusercontent.com/u/489311?v=4"},"body":"On Fri, Mar 14, 2014 at 1:39 PM, Jagan Teki <jagannadh.teki@gmail.com> wrote:\n> Suppose developer send 10 patches on branch1 where are changes in terms\n> of <dir>_<version>/ then I need to apply on my local repo branch1, till now\n> is fine then I need to apply same 10 patches on to my branch2 where source\n> tree <dir> which is quite question here how can I do.\n\nYou might be able to use the subtree option in recursive merge. Try\nsomething like:\n\n    git cherry-pick -X subtree=foo <commit>\n\nThis tells git to apply the changes to the \"foo\" directory in your\ncurrent branch (branch2).\n"},{"id":"236743","messageId":"CAD6G_RSmpfhTr_qtdaChR9TqMZgn8BAuSNDmK5B3HJDZMyoM1Q@mail.gmail.com","threadId":"36157","inReplyTo":"CADeaMWpw4gx00QpUJ7u49sQvu7KbhvhH14TMdHXBRXq4wCNDZA@mail.gmail.com","subject":"Re: Apply commits from one branch to another branch (tree structure is different)","fromName":"Jagan Teki","fromEmail":"jagannadh.teki@gmail.com","sentAt":"2014-03-14T20:01:15Z","receivedAt":"2014-03-14T20:01:15Z","isPatch":false,"sender":{"key":"jagannadh.teki@gmail.com","avatar":null},"body":"On Sat, Mar 15, 2014 at 12:48 AM, Andrew Wong <andrew.kw.w@gmail.com> wrote:\n> On Fri, Mar 14, 2014 at 1:39 PM, Jagan Teki <jagannadh.teki@gmail.com> wrote:\n>> Suppose developer send 10 patches on branch1 where are changes in terms\n>> of <dir>_<version>/ then I need to apply on my local repo branch1, till now\n>> is fine then I need to apply same 10 patches on to my branch2 where source\n>> tree <dir> which is quite question here how can I do.\n>\n> You might be able to use the subtree option in recursive merge. Try\n> something like:\n>\n>     git cherry-pick -X subtree=foo <commit>\n>\n> This tells git to apply the changes to the \"foo\" directory in your\n> current branch (branch2).\n\nHow do I do this?\n\nSuppose I'm in branch1 with two commits on foo_v2 and I need to apply them\non branch2 where in foo.\n\nthanks!\n-- \nJagan.\n"},{"id":"236744","messageId":"CADgNjan2SQXXfYfMP0sk5tqY_=c68=y0dfANF_KFaPQpzNG3yA@mail.gmail.com","threadId":"36157","inReplyTo":"CAD6G_RSmpfhTr_qtdaChR9TqMZgn8BAuSNDmK5B3HJDZMyoM1Q@mail.gmail.com","subject":"Re: Apply commits from one branch to another branch (tree structure is different)","fromName":"Andrew Wong","fromEmail":"andrew.kw.w@gmail.com","sentAt":"2014-03-14T20:37:01Z","receivedAt":"2014-03-14T20:37:01Z","isPatch":false,"sender":{"key":"andrew.kw.w@gmail.com","avatar":"https://avatars.githubusercontent.com/u/489311?v=4"},"body":"On Fri, Mar 14, 2014 at 4:01 PM, Jagan Teki <jagannadh.teki@gmail.com> wrote:\n> On Sat, Mar 15, 2014 at 12:48 AM, Andrew Wong <andrew.kw.w@gmail.com> wrote:\n>> On Fri, Mar 14, 2014 at 1:39 PM, Jagan Teki <jagannadh.teki@gmail.com> wrote:\n>>> Suppose developer send 10 patches on branch1 where are changes in terms\n>>> of <dir>_<version>/ then I need to apply on my local repo branch1, till now\n>>> is fine then I need to apply same 10 patches on to my branch2 where source\n>>> tree <dir> which is quite question here how can I do.\n>>\n>> You might be able to use the subtree option in recursive merge. Try\n>> something like:\n>>\n>>     git cherry-pick -X subtree=foo <commit>\n>>\n>> This tells git to apply the changes to the \"foo\" directory in your\n>> current branch (branch2).\n>\n> How do I do this?\n>\n> Suppose I'm in branch1 with two commits on foo_v2 and I need to apply them\n> on branch2 where in foo.\n\nSince this uses cherry-pick, the changes that you want to apply have\nto be on branch1 already.\n\nLet's say your branch1 looks like:\n    --A--B--C--D\nand branch2 looks like:\n    --1--2--3--4\n\nAnd you want to apply commits B and C on branch2, but they modify\n\"foo_v1/\" on branch1. You can tell git to apply the commits onto the\ndirectory \"foo/\" on branch2:\n    git checkout branch2    # make sure you're on branch2\n    git cherry-pick -X subtree=foo B C    # pick the commits\n\nIf there's no conflict, the commits should apply cleanly, and your\nbranch2 would become like:\n    --1--2--3--4--B'--C'\n"},{"id":"236747","messageId":"CAD6G_RTzbJGc10doV_ZbC5bd=Zpr6rPbNXni+Yo7cxD38DCLMQ@mail.gmail.com","threadId":"36157","inReplyTo":"CADgNjan2SQXXfYfMP0sk5tqY_=c68=y0dfANF_KFaPQpzNG3yA@mail.gmail.com","subject":"Re: Apply commits from one branch to another branch (tree structure is different)","fromName":"Jagan Teki","fromEmail":"jagannadh.teki@gmail.com","sentAt":"2014-03-14T20:57:31Z","receivedAt":"2014-03-14T20:57:31Z","isPatch":false,"sender":{"key":"jagannadh.teki@gmail.com","avatar":null},"body":"On Sat, Mar 15, 2014 at 2:07 AM, Andrew Wong <andrew.kw.w@gmail.com> wrote:\n> On Fri, Mar 14, 2014 at 4:01 PM, Jagan Teki <jagannadh.teki@gmail.com> wrote:\n>> On Sat, Mar 15, 2014 at 12:48 AM, Andrew Wong <andrew.kw.w@gmail.com> wrote:\n>>> On Fri, Mar 14, 2014 at 1:39 PM, Jagan Teki <jagannadh.teki@gmail.com> wrote:\n>>>> Suppose developer send 10 patches on branch1 where are changes in terms\n>>>> of <dir>_<version>/ then I need to apply on my local repo branch1, till now\n>>>> is fine then I need to apply same 10 patches on to my branch2 where source\n>>>> tree <dir> which is quite question here how can I do.\n>>>\n>>> You might be able to use the subtree option in recursive merge. Try\n>>> something like:\n>>>\n>>>     git cherry-pick -X subtree=foo <commit>\n>>>\n>>> This tells git to apply the changes to the \"foo\" directory in your\n>>> current branch (branch2).\n>>\n>> How do I do this?\n>>\n>> Suppose I'm in branch1 with two commits on foo_v2 and I need to apply them\n>> on branch2 where in foo.\n>\n> Since this uses cherry-pick, the changes that you want to apply have\n> to be on branch1 already.\n>\n> Let's say your branch1 looks like:\n>     --A--B--C--D\n> and branch2 looks like:\n>     --1--2--3--4\n>\n> And you want to apply commits B and C on branch2, but they modify\n> \"foo_v1/\" on branch1. You can tell git to apply the commits onto the\n> directory \"foo/\" on branch2:\n>     git checkout branch2    # make sure you're on branch2\n>     git cherry-pick -X subtree=foo B C    # pick the commits\n>\n> If there's no conflict, the commits should apply cleanly, and your\n> branch2 would become like:\n>     --1--2--3--4--B'--C'\n\nI created two commits on foo_v2 when I move branch2 and\ndid cherry-pick it shows below:\n\nMr.J> git cherry-pick -X subtree=foo\ncc70089614de16b46c08f32ea61c972fea2132ce\n14e9c9b20e3bf914f6a38ec720896b3d67f94c90\nerror: could not apply cc70089... AAAAAAAAAAAAAAAAA\nhint: after resolving the conflicts, mark the corrected paths\nhint: with 'git add <paths>' or 'git rm <paths>'\nhint: and commit the result with 'git commit'\nMr.J> ls\nfoo\nMr.J> gs\n# On branch branch2\n# Unmerged paths:\n#   (use \"git add/rm <file>...\" as appropriate to mark resolution)\n#\n#    deleted by us:      foo/foo_v2/test.txt\n#\nno changes added to commit (use \"git add\" and/or \"git commit -a\")\n\nthanks!\n-- \nJagan.\n"},{"id":"236754","messageId":"CADgNjan7iDOgzXd4Ue69tM9CztM8OmHqzD6yEW7e6v8oM_yBxQ@mail.gmail.com","threadId":"36157","inReplyTo":"CAD6G_RTzbJGc10doV_ZbC5bd=Zpr6rPbNXni+Yo7cxD38DCLMQ@mail.gmail.com","subject":"Re: Apply commits from one branch to another branch (tree structure is different)","fromName":"Andrew Wong","fromEmail":"andrew.kw.w@gmail.com","sentAt":"2014-03-14T21:57:13Z","receivedAt":"2014-03-14T21:57:13Z","isPatch":false,"sender":{"key":"andrew.kw.w@gmail.com","avatar":"https://avatars.githubusercontent.com/u/489311?v=4"},"body":"On Fri, Mar 14, 2014 at 4:57 PM, Jagan Teki <jagannadh.teki@gmail.com> wrote:\n> Mr.J> git cherry-pick -X subtree=foo\n> cc70089614de16b46c08f32ea61c972fea2132ce\n> 14e9c9b20e3bf914f6a38ec720896b3d67f94c90\n> error: could not apply cc70089... AAAAAAAAAAAAAAAAA\n> hint: after resolving the conflicts, mark the corrected paths\n> hint: with 'git add <paths>' or 'git rm <paths>'\n> hint: and commit the result with 'git commit'\n> Mr.J> ls\n> foo\n> Mr.J> gs\n> # On branch branch2\n> # Unmerged paths:\n> #   (use \"git add/rm <file>...\" as appropriate to mark resolution)\n> #\n> #    deleted by us:      foo/foo_v2/test.txt\n> #\n> no changes added to commit (use \"git add\" and/or \"git commit -a\")\n\nDoes the foo_v2/test.txt file already exist in branch2 before you try to apply?\ni.e. does foo/test.txt exist in branch2?\n\nWhat might be happening is: the commit modifies foo_v2/test.txt on\nbranch1, but foo/test.txt doesn't exist on branch2. So even when you\nuse the subtree option, there's no foo/test.txt on branch2 to\n\"receive\" the changes of foo_v2/test.txt. This is an actual conflict\nthat git doesn't know what to do, so you have resolve it. This\nprobably means one of two things for you:\n\n1. You _want_ foo/test.txt on branch2, then:\n        git add foo/foo_v2/test.txt    # get the entire test.txt file\nfrom that commit on branch1\n        git mv foo/foo_v2/test.txt foo/test.txt    # move/rename the\nfile to the right location\n2. You _don't_ want foo/test.txt on branch2, then:\n        git rm foo/foo_v2/test.txt    # just remove it\n\nAnd then run \"git cherry-pick --continue\" to continue with the cherry-pick.\n"},{"id":"236990","messageId":"CANUGeEbBi5OQAcwEK7mLxc+OvxTiRxgUwcqW9awVZcvCWo4eHA@mail.gmail.com","threadId":"36157","inReplyTo":"CAD6G_RSPNob11jzqyXiBR4zRuu3T00+qQ7rhNx_E4q+2-3h6iw@mail.gmail.com","subject":"Re: Apply commits from one branch to another branch (tree structure is different)","fromName":"Brandon McCaig","fromEmail":"bamccaig@gmail.com","sentAt":"2014-03-18T17:11:54Z","receivedAt":"2014-03-18T17:11:54Z","isPatch":false,"sender":{"key":"bamccaig@gmail.com","avatar":"https://gravatar.com/avatar/05b01f2b62a5ddbaa1946579266a8d9e970fed0c0b3c20e8d42aca973c31531c?d=mp&s=160"},"body":"Jagan:\n\nOn Fri, Mar 14, 2014 at 1:11 PM, Jagan Teki <jagannadh.teki@gmail.com> wrote:\n> Don't know what happen, I'm unable to join #git channel\n> [23:40] <Jagan> hi\n> [23:40] == Cannot send to channel: #git\n\nI'm not sure if this is the problem that you were having, but #git on\nfreenode is NickServ protected. You need to register with NickServ (a\nbot on the network) and identify yourself with it in order to be\nallowed to speak in #git. This cuts down on spam. You can `/msg\nNickServ help' to learn how to use it (and also Google will be your\nfriend).\n\nAlternatively, check the channel topic for an alternative solution.\n\nRegards,\n\n\n-- \nBrandon McCaig <bamccaig@gmail.com> <bamccaig@castopulence.org>\nCastopulence Software <https://www.castopulence.org/>\nBlog <http://www.bamccaig.com/>\nperl -E '$_=q{V zrna gur orfg jvgu jung V fnl. }.\nq{Vg qbrfa'\\''g nyjnlf fbhaq gung jnl.};\ntr/A-Ma-mN-Zn-z/N-Zn-zA-Ma-m/;say'\n"},{"id":"236991","messageId":"CANUGeEb6u82=GbnoFiXbWjZmdBtQ_0ObixLcPcKLF-Z0ABgXOQ@mail.gmail.com","threadId":"36157","inReplyTo":"CAD6G_RTZaaYBP0MrmRYhce2v+A+WwvY=97Do3LoWW-SYzkHM2g@mail.gmail.com","subject":"Re: Apply commits from one branch to another branch (tree structure is different)","fromName":"Brandon McCaig","fromEmail":"bamccaig@gmail.com","sentAt":"2014-03-18T17:18:27Z","receivedAt":"2014-03-18T17:18:27Z","isPatch":false,"sender":{"key":"bamccaig@gmail.com","avatar":"https://gravatar.com/avatar/05b01f2b62a5ddbaa1946579266a8d9e970fed0c0b3c20e8d42aca973c31531c?d=mp&s=160"},"body":"Jagan:\n\nOn Fri, Mar 14, 2014 at 12:39 PM, Jagan Teki <jagannadh.teki@gmail.com> wrote:\n> Hi,\n\nHello,\n\n> I have two branch in one repo that I need to maintain for 2 different\n> deliveries.\n> Say branch1 and branch2 in test.git repo.\n>\n> test.git\n> - branch1\n>      foo_v1/text.txt\n>      foo_v2/text.txt\n> - branch2\n>      foo/text.txt\n>\n> branch1 is developers branch all source looks version'ed manner and\n> branch2 is superset for branch1, example foo_v1 and foo_v2 are the directories\n> in branch1 where developer will update the latest one here foo_v2 and branch2\n> foo is same as the latest one of branch1 for an instance.\n>\n> Suppose developer send 10 patches on branch1 where are changes in terms\n> of <dir>_<version>/ then I need to apply on my local repo branch1, till now\n> is fine then I need to apply same 10 patches on to my branch2 where source\n> tree <dir> which is quite question here how can I do.\n>\n> Request for any help! let me know for any questions.\n\nThis just sounds like a painful workflow to me. I would suggest not\ndoing this at all, but rather using tags to mark specific releases,\nand using individual branches for continued development (e.g., stable\nor v1.x or whatever is most appropriate). You can have unstable or\nmaster or dev or whatever for developers to work on freely without\nbreaking releases (albeit, there are many different workflows you can\nuse to manage the transition from unstable to stable code).\n\nI would avoid using subtrees (subdirectories) within a Git repository\nto represent different releases of the code. Git already tracks\nversions. That is redundant and messy. It's really an outdated way of\nthinking about version control.\n\n/my 2 cents\n\nRegards,\n\n\n-- \nBrandon McCaig <bamccaig@gmail.com> <bamccaig@castopulence.org>\nCastopulence Software <https://www.castopulence.org/>\nBlog <http://www.bamccaig.com/>\nperl -E '$_=q{V zrna gur orfg jvgu jung V fnl. }.\nq{Vg qbrfa'\\''g nyjnlf fbhaq gung jnl.};\ntr/A-Ma-mN-Zn-z/N-Zn-zA-Ma-m/;say'\n"}]}