Mani
Mani

Reputation: 741

Merge only one Feature branch changes to master

I have a problem.

  1. Create a Feature branch F1 from DEV
  2. Make Changes in F1, commit the changes and merge F1 to DEV
  3. Create a Feature F2 from DEV
  4. Make Changes in F2, commit and merge F2 to DEV
  5. Now the business decides they want only Feature F2 to migrate to PRODUCTION
  6. So I am trying to merge F2 file changes to MASTER branch
  7. I want only to merge the file changes I did in F2 to MASTER not to pick up the changes from F1

Is it possible? Can you please help me when I merge it is also picking up the changes from F1 to merge to MASTER.

Upvotes: 0

Views: 1084

Answers (1)

Chris Maes
Chris Maes

Reputation: 37712

Is it possible?

Yes, as long as you didn't have conflicts to resolve when merging F2 into DEV:

on masterbranch run git merge F2, since as you describe it, that branch would contain all F2 developments, but not F1. If the branch F2 does not exist anymore, you can replace it with the hash of the commit where F2 pointed to before merging into dev: git merge <last-f2-commit>

Is it a good idea to work like this?

No, as different developments (F1, F2) will sooner or later interact with one another, and so you are moving to production a code that has not been tested as such: F1+F2 has been tested, F2 alone has not.

Feature toggles (or feature flags) might be a good approach here: allowing you to "disable F1" for production. This would also allow your testers to test "F2 only" before going into production. This will also allow you to move further, allowing some refactoring etc.

Upvotes: 2

Related Questions