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

Workflow

the following assumes that all commits will be going into staging, but hotfixes can go directly into production if necessary.

  1. Create a branch off of staging for a new feature
  2. Commit changes to this new branch.
  3. PR to merge into staging.
  4. Merge into staging.
  5. CI automatically deploys to staging.
  6. Test in staging.
  7. When ready, merge staging into production (don't squash)
  8. 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

  1. It's clear what changes are in what environment based on git commits.
  2. Very little overhead.

Cons

  1. Not very common.
  2. Easy to branch off the wrong branch.
  3. Hotfixes will need to be reverse-merged into staging.