How would you roll back a production release using Git?
There are several safe rollback methods:
Option 1 — Revert to a previous tag (recommended):
git revert <commit-hash>
git push origin main
This creates a new commit that undoes the bad release.
Option 2 — Deploy a stable tag:
git checkout v1.2.3
git push origin main --force
Example:
If version v2.0 introduced a bug in the payment flow, I revert to v1.9.1 (the last stable tag)
and redeploy while investigating the issue.
Follow:
In CI/CD pipelines:
We often have a ROLLBACK_TAG variable that can deploy a known safe version
automatically.