The case against `git cherry pick`: Recommended branching strategy for multi-environment dbt projects
This blog post was written before Staging environments. You can now use dbt Cloud can to support the patterns discussed here. Read more about Staging environments.
Why do people cherry pick into upper branches?
The simplest branching strategy for making code changes to your dbt project repository is to have a single main branch with your production-level code. To update the main
branch, a developer will:
- Create a new feature branch directly from the
main
branch - Make changes on said feature branch
- Test locally
- When ready, open a pull request to merge their changes back into the
main
branch
If you are just getting started in dbt and deciding which branching strategy to use, this approach–often referred to as “continuous deployment” or “direct promotion”–is the way to go. It provides many benefits including:
- Fast promotion process to get new changes into production
- Simple branching strategy to manage
The main risk, however, is that your main
branch can become susceptible to bugs that slip through the pull request approval process. In order to have more intensive testing and QA before merging code changes into production, some organizations may decide to create one or more branches between the feature branches and main
.