I may be wrong but it seems that the original question was about changing apps within a given project, rather than simply changing projects.
This answer is about changing apps and site_IDs within a project.
In my case I have a project (CoolProject) with 2 web apps:
- an assessment form:
form
- a main website:
website
Both apps are in separate repos both locally and in GitHub.
Each app has its own specific site_ID:
- form:
coolproject-form[.web.app]
- website:
coolproject-website[.web.app]
I first setup the form app and deployed without any issue to coolproject-form. But when I created the web app (and associated coolproject-website site_ID) and tried to deploy it using firebase deploy --only hosting or firebase deploy --only hosting:website it incorrectly deployed it to coolproject-form overwriting the form app.
This is how I eventually solved the issue (based on this Firebase documentation):
- Check that both apps and corresponding site_IDs are correctly setup:
firebase apps:list
firebase hosting:sites:list
- Setup up the
website deploy target for hosting (via .firebaserc)
firebase target:apply hosting website coolproject-website
- Update
firebase.json (for the website app):
...
"hosting": [{
"target": "website",
"public": "build",
"ignore": [
"firebase.json",
"**/.*",
"**/node_modules/**"
],
"rewrites": [
{
"source": "**",
"destination": "/index.html"
}
]
}],
...
- Deploy
firebase deploy --only hosting
With this the website app is now correctly deployed to coolproject-website.web.app.