0

Scenario:

master
|
\
  dev
  |
  \
    feature1
    |
    |
    |
   /
  |
  /  
tagV1
  |
  \
    feature2
    |
    |
   /
  |
 /
tagV2
  |
  \
    fixForV1
    |
    |
   /
  |
  /  
tagV1_1

Description:

  1. Create repo
  2. Create and checkout branch dev
  3. Create and checkout branch feature1 .. implement the feature
  4. Checkout dev and merge feature1, delete feature1
  5. Checkout master merge dev
  6. Create tagV1 (Will be delivered to the customer)
  7. Checkout dev
  8. Create and checkout branch feature2 .. implement the feature
  9. Checkout dev and merge feature2, delete feature2
  10. Checkout master merge dev
  11. Create tagV2 (Will be delivered same or different customer)
  12. Checkout dev
  13. Create and checkout branch fixForV1 .. implement the fix
  14. Checkout dev and merge fixForV1
  15. ???

15… We need to merge tagV1 and the commits made on fixForV1 (Without including the commits made on feature2). After the merge we will create a new tag tagV1_1 and deliver this to the customer.

I know I can achieve this by doing a cherry-pick {hash of first commit made on fixForV1} ^..{hash of last commit made on fixForV1} Is there a better way to do this?

musium
  • 2,942
  • 3
  • 34
  • 67
  • May I ask why fixFovV1 is based on V2? (also your diagram need more love, it looks like nothing got merged back to master) – number5 Apr 24 '15 at 12:41
  • It’s based on V2 because: This is a simple demo to show my problem. In the real world fixForV1 would be a feature implemented in dev… and now some time later the customer wo has installed v1 asks me to integrate this feature in v1 as well… and since the changes made in feature2 may would break some stuff in v1 I only want to merge the commits made in fixForV1 (Btw. The diagram everything on master has no leading spaces, dev has 2 and the feature branches has 4…and yes it could be prettier sry.) – musium Apr 24 '15 at 12:53

1 Answers1

1

If I understand your requirements correctly, you can also work like this:

  1. git checkout fixForV1
  2. git format-patch tagV2 -- get all the patches from tagV2 to head of fixForV1
  3. git checkout -b branchV1 tagV1 -- create a new branch based on tagV1
  4. git apply *.patch -- apply patches we generated in step 1

If you are lucky, all patches apply without issue then you're done. If not lucky, apply the patches one by one in order then fix the conflicts accordingly.

number5
  • 15,913
  • 3
  • 54
  • 51