Environment-Based Development
Environment-Based Development
Environment-Based Development uses long-lived branches to represent the different environments. In this strategy, main
doesn't exist.
Branches
staging
- what is currently deployed tostaging
production
- what is currently deployed toproduction
Workflow
the following assumes that all commits will be going into staging, but hotfixes can go directly into production if necessary.
- Create a branch off of
staging
for a new feature - Commit changes to this new branch.
- PR to merge into
staging
. - Merge into
staging
. - CI automatically deploys to
staging
. - Test in staging.
- When ready, merge
staging
intoproduction
(don't squash) - CI automatically deploys to
production
--- title: Branch Flow --- %%{init: { 'gitGraph': {'mainBranchName': 'staging'}}}%% gitGraph checkout staging commit branch production order: 3 checkout production commit checkout staging branch feature/01 order: 2 checkout feature/01 commit commit checkout staging merge feature/01 checkout production merge staging
Pros
- It's clear what changes are in what environment based on git commits.
- Very little overhead.
Cons
- Not very common.
- Easy to branch off the wrong branch.
- Hotfixes will need to be reverse-merged into staging.