1

I have staging, development and other three feature branches:-

  1. branch_feature_A
  2. branch_feature_B
  3. branch_feature_C

After each feature branch is tested, I merged all three to development branch. Next am supposed to push development branch features (only branch_feature_A and branch_feature_B) to staging. Given that I had deleted branch_feature_A, branch_feature_B, and branch_feature_C when I was merging to developmet, how can I make sure that I include only branch_feature_A, and branch_feature_B to staging?

Slim Gera
  • 65
  • 1
  • 5
  • A branch name is just like a sticker you use to mark a page in a book. If you remove the sticker, the page is still there, and with enough effort you will find it and you'll be able to put the sticker back. – j6t Aug 30 '22 at 08:54
  • My issue is, how do I remove one of the feature branches from the development branch before I merge development into staging – Slim Gera Aug 31 '22 at 06:43
  • 1
    You don't. You merge the feature branches individually into staging, not the whole development branch. If your corporate workflow requires you to do differently, then that counts as an broken workflow in my book. – j6t Aug 31 '22 at 07:18
  • 1
    @SlimGera I have edited the answer to address your comment/question. – VonC Aug 31 '22 at 08:16

1 Answers1

1

Check first if you cannot restore those deleted branches.

Use the git reflog to see if those branches are still listed.
Or simply use the second parent of the merge commit for each branch to get back each branch HEAD.

From there, you can recreate each branch, and push them to staging.


My issue is, how do I remove one of the feature branches from the development branch before I merge development into staging

You do not. You always merge feature branch to integrations branches (dev, qa, main, ...)

You never merge integration branches between them, precisely because it is complex to sort out exactly what you want to merge.

You can see an illustration of that idea with gitworkflow (one word).

gitworkflow

VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250