Keyboard shortcuts

Press ← or → to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Last updated: Monday 09 November 2026 @ 12:56:44

Continuous Deployment

Git · Delivery workflows

Continuous Deployment

Use a stable mainline, short-lived branches and a controlled deployment simulation to understand how approved changes reach users.

GitHub flowFeature branchesRelease automationHotfixes
Distinguish delivery models

Explain Continuous Integration, Continuous Delivery and Continuous Deployment.

Simulate promotion

Deploy a chosen commit to a local staging and production directory.

Recover safely

Create a hotfix and identify a previous release for rollback.

What is Continuous Deployment?

Continuous Integration checks changes, Continuous Delivery keeps a verified change ready for release, and Continuous Deployment automatically releases successful changes to users. The workflow below models the branching and promotion steps; local commands stand in for a real deployment platform.

Continuous deployment branching overview

Features and hotfixes are integrated into a deployable mainline.

Branch roles

BranchRoleLifetime
mainMaintained, deployable lineLong-lived
feature/*Isolated improvementShort-lived
hotfix/*Urgent repair from the deployed stateShort-lived

Practical: prepare a local deployment

  1. Create a disposable repository with a versioned site file.

    mkdir -p ~/git-deploy-lab && cd ~/git-deploy-lab
    git init -b main
    git config user.name "Git Student"
    git config user.email "student@example.invalid"
    printf 'Sensor dashboard v1\n' > index.txt
    git add index.txt
    git commit -m "feat: initial dashboard"
    git tag v1.0.0
  2. Prepare local directories representing staging and production environments.

    mkdir -p staging production
    cp index.txt production/index.txt
    cat production/index.txt
  3. Record the initially deployed revision.

    git rev-parse v1.0.0
    git log --oneline --decorate -1

Develop a feature

Feature branch integrated into main for deployment

A feature is reviewed and integrated before deployment.

  1. Branch from main, change the version text and commit the feature.

    git switch -c feature/dashboard-v2
    printf 'Sensor dashboard v2\n' > index.txt
    git add index.txt
    git commit -m "feat: update dashboard to v2"
  2. Review the change and integrate it into main.

    git diff main...feature/dashboard-v2
    git switch main
    git merge --no-ff feature/dashboard-v2 -m "merge: dashboard v2"
  3. Copy the checked-out content into the simulated staging environment and verify it.

    cp index.txt staging/index.txt
    cat staging/index.txt
    git log -1 --oneline
  4. Promote the same tested content to production and tag the commit.

    cp staging/index.txt production/index.txt
    git tag v2.0.0
    cat production/index.txt

Parallel features

  1. Start another branch from the current main and add a separate file.

    git switch -c feature/adc-summary
    printf 'ADC values are sampled periodically.\n' > adc.txt
    git add adc.txt
    git commit -m "docs: explain ADC sampling"
  2. Inspect the difference without merging it.

    git diff main...feature/adc-summary
    git log --all --oneline --graph --decorate
  3. Return to main and confirm that adc.txt is not yet in that branch.

    git switch main
    git ls-files adc.txt

Production hotfix and rollback

Hotfix branched from the production mainline

Even urgent production changes should be isolated and verified.

  1. Create a hotfix branch from main (the version currently deployed), not from the unfinished feature branch.

    git switch main
    git switch -c hotfix/dashboard-label
    printf 'Sensor dashboard v2 (verified)\n' > index.txt
    git add index.txt
    git commit -m "fix: clarify dashboard label"
  2. Review, integrate and stage the repair.

    git diff main...hotfix/dashboard-label
    git switch main
    git merge --no-ff hotfix/dashboard-label -m "merge: verified dashboard label"
    cp index.txt staging/index.txt
    cat staging/index.txt
  3. Promote the verified content and create a patch tag.

    cp staging/index.txt production/index.txt
    git tag v2.0.1
    cat production/index.txt
  4. Simulate a rollback without rewriting Git history: restore the previously tagged content to the production directory.

    git show v2.0.0:index.txt > production/index.txt
    cat production/index.txt
    git log -3 --oneline

Further reading