A key thing that git-flow was intended to address was the ability to reason about the role of a given branch, and what it branches from and merges to.
Ideally, all branches merge back to the codeline they were merged from. This is typically a merge from the mainline (in git-flow this is dev
). Feature branches branch and merge from dev, release branches branch and merge from dev (with an additional merge to master
). Hot fixes branch and merge from master (with that additional merge back to dev).
Each codeline branches from and merges back to its parent. A codeline may pull in code from other codelines at any time if it is necessary.
If the branch from a feature branch is a "I want to explore this way of fixing a problem in that feature branch" - perfectly fine. It branches from the feature branch, commits some code and merges back to the feature branch (or is discarded).
- branch from feature
- explore idea
- merge to feature
What you want to avoid however is something that looks like:
- branch from required-feature
- work on code
- merge from dev once required-feature is complete
- verify functionality (and additional commits) in feature branch
- merge to dev
The reason is that the start and the end don't match - it makes it a little bit harder to understand what this is and was. Not impossible, but it just makes it
take a little bit more time for someone to understand its role.
However, if this is new feature that depends code that isn't yet found in dev, the flow should be:
- branch from dev
- merge from required-feature
- work on code
- merge from dev once required-feature is complete
- verify functionality (and additional commits) in feature branch
- merge to dev
Note that this starts with a branch from dev and ends with a merge to dev.
All that said, probably the best thing to do is to avoid doing a merge from one feature to another feature. Branch the feature, do whatever preliminaries are needed... and wait.
- branch from dev
- work on code
- merge from dev once required-feature is complete
- verify functionality (and additional commits) in feature branch
- merge to dev
This provides the most stable set of branches and code.
Something to consider for future work would be to have a feature to publish the necessary interfaces for interoperability with other features - even if the implementation code isn't complete. This would be merged to dev, and then required-feature could work off of those interfaces as could the future-feature. This would likely allow future-feature to progress further (coding against the interfaces, testing against stubbs that implement the interfaces) than it would if it had to wait for required-feature to merge to dev.