'Git - some commit go production first, how to manage dev/stg/master branch

Good day,

I have 3 environment: dev/stg/master, I usually develop on dev branch, customer usually request some feature, and I create feature branch from dev to develop. After developed, I merge to dev and stg.

Someday, after I did 5 same things, there are 5 feature on dev/stg, lets named feature A, B, C, D, E. Customer asked me to release feature C & D to master, I used to cherry-pick to master. The reason was there are some bug had be discovered on stg, so I did some fix commit on stg (also cherry-pick back to dev).

But A, B, E still on stg and dev some month, I think they already forgot these feature or no longer nesssary, but I still develop new features that customer requested.

These three branch code is more and more different since project beginning.

Is any suggestion or existing flow can help this situation?

git


Solution 1:[1]

The best way is to develop each feature in isolation in a separate "feature" branch. Then you can choose which features have to be merged into the "release" branch. The key here is to keep "feature" branches up-to-date with branch the were started from.

This is a pretty standard workflow named "Feature Branch Flow" More detailed explanation at https://www.atlassian.com/git/tutorials/comparing-workflows/feature-branch-workflow

There are several other workflows you can find useful there. "Git Flow" is one of the most popular ones.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Eugene Ryzhikov