0
0
FirebaseHow-ToBeginner Ā· 3 min read

How to Rollback Deployment on Firebase Hosting Quickly

To rollback a Firebase Hosting deployment, use the firebase hosting:rollback command followed by the site name and the version number you want to restore. This command reverts your live site to a previous deployed version easily and safely.
šŸ“

Syntax

The rollback command uses this pattern:

  • firebase hosting:rollback [options]
  • --site <site-name>: Specify your Firebase Hosting site if you have multiple sites.
  • --version <version-id>: The version ID to rollback to, which you get from your deployment history.
bash
firebase hosting:rollback --site your-site-name --version VERSION_ID
šŸ’»

Example

This example shows how to rollback to a previous version of your Firebase Hosting site named my-cool-site. First, find the version ID from your deployment history, then run the rollback command.

bash
firebase hosting:rollback --site my-cool-site --version 1a2b3c4d5e
Output
āœ” Hosting site my-cool-site has been rolled back to version 1a2b3c4d5e āœ” Deployment complete
āš ļø

Common Pitfalls

Common mistakes when rolling back Firebase Hosting include:

  • Not specifying the --site option when you have multiple sites, causing rollback to fail.
  • Using an incorrect or non-existent version-id, which results in an error.
  • Trying to rollback without being logged in or without proper Firebase CLI setup.

Always check your deployment history with firebase hosting:versions:list --site your-site-name to get valid version IDs.

bash
firebase hosting:rollback --version wrong-version-id
# This will fail because the version ID is invalid

# Correct way:
firebase hosting:rollback --site my-cool-site --version valid-version-id
Output
Error: Version 'wrong-version-id' not found. āœ” Hosting site my-cool-site has been rolled back to version valid-version-id āœ” Deployment complete
šŸ“Š

Quick Reference

CommandDescription
firebase hosting:rollback --site --version Rollback to a specific deployed version
firebase hosting:versions:list --site List all deployed versions for your site
firebase loginLogin to Firebase CLI if not already logged in
firebase deployDeploy new changes to Firebase Hosting
āœ…

Key Takeaways

Use firebase hosting:rollback with the correct site and version to revert your site.
Always list versions with firebase hosting:versions:list to find valid version IDs.
Specify the --site option if you manage multiple Firebase Hosting sites.
Ensure you are logged in to Firebase CLI before running rollback commands.
Rollback does not delete versions; it simply makes a previous version live again.