Rollbacks

Safely revert deployments to any previous version. Instant rollbacks, point-in-time recovery, and zero-downtime strategies.

📖 12 min read
🕐 Updated Dec 2024
🏷 v2.4+

Overview

Rollbacks are a critical safety net in your deployment workflow. .git provides multiple rollback strategies to handle any scenario — from a quick undo of a bad deployment to a precise point-in-time recovery of your entire application state.

Every deployment is automatically versioned and stored, allowing you to revert to any previous deployment within your retention window (configurable per environment).

💡

Best practice: Always configure automatic rollback triggers for your production environment. Combine health checks with automated rollbacks to minimize downtime.

Rollback Strategies

.git supports four rollback strategies. Choose the one that best fits your deployment model and risk tolerance.

Instant Rollback

Revert to the previous deployment in under 1 second. Traffic is instantly redirected without rebuilding.

Sub-second
🕐

Point-in-Time

Restore your application to any specific timestamp. Includes database migrations and file state.

Precise
🔬

Canary Revert

Automatically roll back canary deployments when error thresholds are exceeded during gradual rollout.

Auto-triggered
🔄

Blue/Green Swap

Instantly swap traffic back to the previous environment. Zero downtime with full isolation.

Zero Downtime

Using the CLI

Perform rollbacks directly from the command line using the git rollback command.

Terminal
# Rollback to the previous deployment git rollback --environment production # Rollback to a specific deployment ID git rollback --deployment dep_abc123 # Point-in-time rollback git rollback --time "2024-12-15T10:30:00Z" # Rollback with database migration revert git rollback --with-migrations --environment production # Dry run — preview rollback without executing git rollback --dry-run

Rollback from the Dashboard

You can also trigger rollbacks from the Deployments page in your dashboard:

1

Navigate to Deployments

Go to your project dashboard and select the Deployments tab. View the deployment history timeline.

2

Select a Target Deployment

Click on any previous deployment to view its details. A Rollback to This Version button appears in the action bar.

3

Confirm & Execute

Review the rollback summary — including affected services, migration changes, and estimated downtime. Confirm to execute.

Instant feedback: After confirming, you'll see real-time progress in the dashboard and terminal. Most rollbacks complete in under 5 seconds.

Automatic Rollbacks

Configure automatic rollbacks to trigger when health checks fail or error rates exceed defined thresholds.

YAML — .gitconfig
rollbacks: auto_trigger: true health_check: path: /health interval: 10s timeout: 5s failure_threshold: 3 # rollback after 3 consecutive failures error_rate: enabled: true threshold: 5% # rollback if 5xx rate exceeds 5% window: 60s # evaluate over 60-second window migration_guard: true # prevent rollback if migrations are irreversible
⚠️

Migration safety: If migration_guard is enabled, automatic rollbacks will be blocked when the target deployment includes irreversible database migrations. You'll need to approve manually.

API Reference

Trigger and manage rollbacks programmatically using the REST API.

REST API
POST https://api.git.dev/v2/projects/:id/rollbacks Headers: Authorization: Bearer <your-token> Content-Type: application/json Body: { "deployment_id": "dep_abc123", "environment": "production", "strategy": "instant", "revert_migrations": false, "notify": ["slack", "email"] } Response: { "rollback_id": "rb_9x8k2m", "status": "in_progress", "started_at": "2024-12-15T14:22:01Z", "estimated_completion": "2024-12-15T14:22:04Z" }

Strategy Comparison

Feature Instant Point-in-Time Canary Blue/Green
Speed < 1s 10–30s Auto < 1s
Downtime ✓ None ~2–5s ✓ None ✓ None
DB Migration Revert
File State Restore
Auto-trigger Support
Best For Quick fixes Full recovery Gradual rollouts Zero-downtime ops

Best Practices

  1. Test rollbacks in staging first. Run rollback simulations in your staging environment to verify the process works as expected.
  2. Set up health check rollbacks. Configure automatic rollbacks based on health check failures to catch issues before they impact users.
  3. Use rollback dry runs. Always preview a rollback with --dry-run to understand what will change before executing.
  4. Document rollback procedures. Keep runbooks updated with rollback steps specific to your project architecture.
  5. Monitor rollback frequency. High rollback rates may indicate deeper issues in your CI/CD pipeline or testing coverage.
  6. Set appropriate retention windows. Ensure you keep enough deployment history for your recovery needs (default: 90 days for production).
🚨

Irreversible migrations: Database migrations that destroy data (e.g., DROP TABLE, DROP COLUMN) cannot be safely reverted. Always backup before deploying migrations that may require rollback.

Monitoring Rollbacks

Track rollback events in real-time through the Observability Dashboard and set up alerts for rollback events:

Webhook Payload — Rollback Event
{ "event": "rollback.completed", "project_id": "proj_x7k2m", "environment": "production", "rollback": { "id": "rb_9x8k2m", "strategy": "instant", "from_deployment": "dep_new456", "to_deployment": "dep_abc123", "trigger": "manual", "duration_ms": 847, "status": "success" } }

Retention & Limits

Deployment versions are retained based on your plan and environment configuration:

Plan Staging Retention Production Retention Max Deployments Stored
Starter 30 days 30 days 50
Pro 90 days 90 days 500
Enterprise 180 days Unlimited Unlimited

Frequently Asked Questions

How fast is an instant rollback? +
Instant rollbacks typically complete in under 1 second for serverless deployments and under 5 seconds for container-based deployments. The rollback works by switching the traffic router to point to the previous deployment's infrastructure — no rebuilding or redeploying is required.
Can I rollback database changes? +
Yes, with point-in-time rollbacks only. This strategy replays your database to the state it was at the target timestamp. Standard instant rollbacks do not affect the database — only the application code and configuration are reverted. Always review migration reversibility before deploying.
What happens to active users during a rollback? +
For instant and blue/green rollbacks, active users experience zero disruption — their requests are seamlessly routed to the previous deployment. For point-in-time rollbacks, there may be a brief window (2–5 seconds) where new connections are temporarily queued during the database restore.
Can I rollback from the mobile app? +
The .git mobile app supports instant rollbacks from any environment. You'll receive push notifications for automatic rollback triggers and can approve or dismiss them on the go. Full point-in-time rollbacks require the web dashboard or CLI.
Are rollbacks available for monorepos? +
Yes. For monorepo setups, .git supports selective rollbacks — you can roll back individual services within the monorepo without affecting others. Use --service flag to target specific services. Example: git rollback --service payments --environment production

Ready to deploy with confidence?

Start using .git rollbacks today. Every plan includes instant rollback support.