oliverdavies.uk/source/_daily_emails/2023-09-26.md

37 lines
1.6 KiB
Markdown
Raw Normal View History

2024-01-03 20:00:00 +00:00
---
title: >
2024-09-08 22:09:54 +00:00
Which branch should be in which environment?
2024-01-03 20:00:00 +00:00
pubDate: 2023-09-26
permalink: >-
2024-09-08 22:09:54 +00:00
archive/2023/09/26/which-branch-should-be-in-which-environment
2024-01-03 20:00:00 +00:00
tags:
2024-09-08 22:09:54 +00:00
- software-development
- git
- trunk-based-development
- feature-flags
2024-01-03 20:00:00 +00:00
---
A common question is which [Git] branch should be on which environment.
Most projects I've worked on have two or more environments: production, staging (or test) and development.
Earlier in my career, we used Git Flow heavily. A Git branching workflow based on having different branches - i.e. `develop`, `master` and any arbitrary short-lived feature, hotfix and release branches.
These matched nicely with our three environments.
Usually, the `develop` branch would be used in the development environment. The `master` branch would be on staging and a tagged release from `master` on production.
## What about now?
I prefer trunk-based development, where there is one long-lived branch to which everyone commits their changes.
There's only one branch, so you can either follow continuous deployment and use the same branch for all environments - including production - or separate production using a dedicated branch or tag if you need more control.
The mainline branch is used in all pre-production environments, such as staging and development.
## What about differences between the environments?
What if we need differences, such as a feature that must be enabled in a particular environment if the same code is on both?
My go-to approach is feature flagging, and this approach is something I'll describe more in tomorrow's email.