It is common for people to want to run the same app in both development and production, connected to different Data Tables in each case. To do this, we create two Anvil apps, git clone one of them locally, then push the same source code to both. Each app will have its own Data Tables and URLs.
We walk through the setup and general workflow below.
- Clone your app in the Anvil Editor
- Rename the app with the full history ‘App Dev’ and the new one ‘App Prod’
- Git Clone ‘App Dev’ to your local machine. If you click the Clone with Git button in the Version History dialog, you will see the git clone command has been generated for you:
# Clone App Dev into the my-app folder (using the APP_ID for 'App Dev') $ git clone ssh://firstname.lastname@example.org:2222/T7ZJCKPBUN4AVGLM.git my-app/ $ cd my-app/
- Open ‘App Prod’, and find the git clone command
- Add a production remote using this ‘App Prod’ git clone command
# Using the APP_ID for 'App Prod' $ git remote add production ssh://email@example.com:2222/Y5AFTQTAUL7GPVCM.git
- Push to production to synchronise ‘App Dev’ and ‘App Prod’
# Push to production from master, to make sure your apps are both in sync # The first time you push to Production, you'll need to force push $ git push --force production master
Your apps are now synchronised with one another, and you have a separate remote set up for your Production version.
- Work on ‘App Dev’ either in the browser or locally
- Make a note of any changes you make to your Data Table schema
- When ‘App Dev’ works, pull it to your local repository
# Pull App Dev locally $ git pull
- Now you’re ready to push to Production
- Reflect any changes made to your Data Tables schema in ‘App Prod’
- Push to Prod:
# Push from master to production (no need to force push this time) $ git push production master
- Refresh ‘App Prod’ in your Browser, and you’ll see it’s been updated for the changes you made to App Dev.
If you’re using the App Secrets service in your app, encrypted secrets won’t be shared between your Development and Production apps by default. This is because the encryption uses an app-specific key (as well as a global key), which will naturally differ between your Dev and Prod apps.
<APP_ID> is a unique ID for your app that never changes (you can access it from code using
You will find your App ID in the URL while editing your app:
You can also access App IDs from your app’s Clone link. Clone links have the form:
Data Tables & Schema
- The Git repos don’t contain data from your Data Tables or your schema
- If you use different Data Tables for Dev and Prod, give your tables the same name so the same code will work on both apps.