Version control

Anvil stores a version history for each app, meaning you can restore previous versions as well as publishing a particular version and working on another.

The entire Anvil app consists of files in a Git repository, so you can work on your app locally and use Git to build custom workflows. (See Version Control:Git for more information)

Version history in the Editor

At the bottom of the App Browser, you can open the Version History of your app.

The version history dialog shows you the history of your app. Each time you save a version, a new entry is made in this list. You can set a name for a version when you save, which makes it easier for you to remember it later. This name is a custom git commit message.

The Version History dialog. There is a tree of commits, one of which is published, There are buttons to save the current version, and to clone the app with Git.

‘Restore this version’ was clicked on the ‘Small Change’ commit.

You can go back to a previous version by clicking Restore this version. This lets you try changes, and then back them out if they don’t work.

In the image above, the Anvil developer has clicked on ‘Restore this version’ for the commit marked ‘Small Change’, and they can continue editing the app from there. New commits will be added on top of ‘Small Change’.

Published vs. Dev versions

You can publish a particular version of your app by clicking Publish in the Version History dialog.

This means that anyone who visits your app sees that version, whatever you’re doing in the editor. It lets you carry on working on an app even while other people are using it.

You can also click ‘Unpublish’ if you want to go back to having the published version the same as the development version.

To find out which version of your app is running in code, use anvil.app.branch. If you run the app in the Anvil Editor, anvil.app.branch will be "master"; if you have published a version of your app and you’re running that, it will be "published".

from anvil import *

if app.branch == 'published':
  print("We are on the published branch")

(In client code you automatically have from anvil import * so it’s available simply as app)