{"thread":{"id":"26648","subject":"1 patch to two branches","startedAt":"2011-03-03T12:46:36Z","lastAt":"2011-03-07T00:56:21Z","messageCount":2,"participants":["allstars","Neal Kreitzinger"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"162720","messageId":"38ac3be3-8d09-4a38-b31e-9365fe0f2992@v11g2000prb.googlegroups.com","threadId":"26648","inReplyTo":null,"subject":"1 patch to two branches","fromName":"allstars","fromEmail":"allstars.chh@gmail.com","sentAt":"2011-03-03T12:46:36Z","receivedAt":"2011-03-03T12:46:36Z","isPatch":false,"sender":{"key":"allstars.chh@gmail.com","avatar":null},"body":"hi\nmy case is as follows\nI have two branches\nbasically they are the same, except they differ from different package\nname(java) and namespace(cpp) due to customer request\n\nbut now I have a fix , say a patch\nI want to commit it to both branches\n\nbut I am lazy so I just want to do just one 'git commit' and 'git\npush'\n\nso I am thinking using a githook in remote server\nand each commit to branch A can also commit to branch B as well\n\nbut I am not quite sure what I should use in the hook\n\ngit rebase , git merge or git cherry pick ?\n\nseems these 3 ways all lead to the same result\nbut I dont know which is better and why\n\n\nthanks\n"},{"id":"162889","messageId":"4D742D35.6080709@gmail.com","threadId":"26648","inReplyTo":"38ac3be3-8d09-4a38-b31e-9365fe0f2992@v11g2000prb.googlegroups.com","subject":"Re: 1 patch to two branches","fromName":"Neal Kreitzinger","fromEmail":"nkreitzinger@gmail.com","sentAt":"2011-03-07T00:56:21Z","receivedAt":"2011-03-07T00:56:21Z","isPatch":false,"sender":{"key":"nkreitzinger@gmail.com","avatar":null},"body":"On 3/3/2011 6:46 AM, allstars wrote:\n> my case is as follows\n> I have two branches\n> basically they are the same, except they differ from different package\n> name(java) and namespace(cpp) due to customer request\n>\n> but now I have a fix , say a patch\n> I want to commit it to both branches\n>\n> but I am lazy so I just want to do just one 'git commit' and 'git\n> push'\n>\n> so I am thinking using a githook in remote server\n> and each commit to branch A can also commit to branch B as well\n>\n> but I am not quite sure what I should use in the hook\n>\n> git rebase , git merge or git cherry pick ?\n>\n> seems these 3 ways all lead to the same result\n> but I dont know which is better and why\n\nif by \"patch\" you mean git-am/git-apply then I'm afraid i don't have any \nsuggestions because i don't use those commands.  However, if you use \ngit-push then have you thought about having a script on the local side \nthat does something like this:\n\n$ git checkout java-branch\n(hack hack)\n$ git add .\n$ git commit\n$ bash -v myscript  <--run your script\n#!/bin/sh\n# script to commit java-branch head to cpp-branch and push them both\ngit checkout cpp-branch &&\nwait\ngit cherry-pick java-branch &&\nwait\ngit push origin HEAD &&\nwait\ngit checkout java-branch &&\nwait\ngit push origin HEAD &&\nwait\nexit 0\n\nof course, you need some error checking in there.  this is predicated on \nthe assumption that the cherry-pick will not get any conflicts.  if it \ndoes get conflicts then you will have to resolve them manually and that \nis a big reason to do this on the local side instead of the remote side.\n\nv/r,\nneal\n"}]}