Branching and merging best practices in Git
git, git-flow
Solution
We settled on a workflow called Git Flow, but instead of branching features from dev, we branch them from the current release. This makes us able to work on seperate issues in different speeds. If they are successful in QA, they go into the release.
Regarding branches and deployment:
- The dev branch is deployed automatically to test servers.
- The current release branch is deployed automatically to staging servers.
- The master branch is deployed manually to live servers by the release-master.
The workflow is the following:
- Create a release branch from master in the beginning of each release/sprint, e.g. release/2015-may .
- Create a dev branch from release/2015-may
- Working on a new feature, branch from release and name it feature/`ISSUE_NUMBER`.
- Work on your feature.
- When it's ready for testing, merge it into dev.
- If it's accepted, merge it into the current release branch.
- If it's not accepted, go to step 4.
- When the release is ready, merge it into master
After the release has been deployed to live and a critical bug is discovered, we branch a hotfix branch from master (e.g. hotfix/`ISSUE_NUMBER`), merge it back into master and deploy again.
Problem
We have a developer team of 4 and have recently moved to Git. We want to learn best practices regarding workflow with branching and merging. We are using a lightweight version of Git Flow. We have a dev, staging and a master branch which are all linear with each other. - staging is branched from master - dev is branched from staging On top of that we use feature and hotfix branches to work on new features and fix bugs. I have the following questions: - Should we branch feature branches from dev or from master? - When a feature branch is ready, should we merge the feature branch into dev, then merge dev into staging, or merge the feature branch into staging and then the feature branch into master? I think we should branch from master and merge the feature branch up, because there might be something in dev that we might not want to merge to staging and master. What is your opinion? What are the best practices?