Tình huống khẩn cấp — ưu tiên speed và safety:
Option 1: Deploy từ previous tag (nhanh nhất, an toàn nhất):
git checkout v2.3.1 # version trước khi deploy — sẽ ở detached HEAD state
# Tạo branch tạm hoặc trigger CI/CD từ tag trực tiếp
# Rebuild và deploy
# Git history không thay đổi gìPhù hợp khi: CI/CD pipeline deploy từ tag, có artifact của version trước sẵn sàng. Lưu ý: git checkout <tag> đặt repo vào detached HEAD — tốt nhất là trigger CI/CD pipeline từ tag thay vì build thủ công.
Option 2: git revert (nếu không có artifact):
git revert -m 1 <merge-commit-hash> # revert PR merge
# hoặc revert từng commit:
git revert HEAD~3..HEAD
git push origin main
# Trigger deploySo sánh:
- Tag redeploy: nhanh hơn, không thay đổi git history, artifact cũ có thể đã có sẵn
- Revert: tạo rõ ràng record "chúng ta đã revert", dễ re-apply sau khi fix
Sau emergency:
# Fix bug trên feature branch
# Revert the revert (nếu dùng revert):
git revert <revert-commit> # re-enables the feature
# Test kỹ, deploy lạiQuan trọng: không xóa revert commit hay dùng reset trên main — cần audit trail.
Post-mortem sau khi ổn định: tại sao bug qua được CI?
Emergency — prioritize speed and safety:
Option 1: Redeploy from previous tag (fastest, safest):
git checkout v2.3.1 # version before the bad deploy — puts repo in detached HEAD state
# Best practice: trigger CI/CD pipeline from the tag directly, rather than building manually
# Git history is unchangedBest when: CI/CD pipeline deploys from tags, previous artifact is already available. Note: git checkout <tag> creates a detached HEAD — trigger CI/CD from the tag instead of running a manual build from that state.
Option 2: git revert (when no artifact is available):
git revert -m 1 <merge-commit-hash> # revert the PR merge
# or revert individual commits:
git revert HEAD~3..HEAD
git push origin main
# Trigger deployComparison:
- Tag redeploy: faster, no history change, old artifact may already be cached
- Revert: creates a clear record of "we rolled back", easier to re-apply after fixing
After the emergency:
# Fix bug on a feature branch
# Revert the revert (if you used revert):
git revert <revert-commit> # re-enables the feature
# Test thoroughly, redeployImportant: never delete revert commits or use reset on main — you need the audit trail.
Write a post-mortem after stabilization: how did the bug get past CI?