Continuous Deployment
Continuous Deployment
Use a stable mainline, short-lived branches and a controlled deployment simulation to understand how approved changes reach users.
Explain Continuous Integration, Continuous Delivery and Continuous Deployment.
Deploy a chosen commit to a local staging and production directory.
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.

Features and hotfixes are integrated into a deployable mainline.
Branch roles
| Branch | Role | Lifetime |
|---|---|---|
main | Maintained, deployable line | Long-lived |
feature/* | Isolated improvement | Short-lived |
hotfix/* | Urgent repair from the deployed state | Short-lived |
Practical: prepare a local deployment
-
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 -
Prepare local directories representing staging and production environments.
mkdir -p staging production cp index.txt production/index.txt cat production/index.txt -
Record the initially deployed revision.
git rev-parse v1.0.0 git log --oneline --decorate -1
Develop a feature

A feature is reviewed and integrated before deployment.
-
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" -
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" -
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 -
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
-
Start another branch from the current
mainand 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" -
Inspect the difference without merging it.
git diff main...feature/adc-summary git log --all --oneline --graph --decorate -
Return to
mainand confirm thatadc.txtis not yet in that branch.git switch main git ls-files adc.txt
Production hotfix and rollback

Even urgent production changes should be isolated and verified.
-
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" -
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 -
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 -
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