Best Version Control Options

I attempted to implement this idea: performing testing in a separate Anvil app and using git to move code between them, but I found it very awkward at first. In the process of writing this post, though, I came to see a more sensible workflow.

Maybe other Git noobs will find it helpful to learn from the mistakes, so I kept my initial draft here.

Here is what I did in my first attempt:

  1. Clone with Git my “production app” onto my local machine.
  2. Create a clone of my production app within Anvil to serve as the “development app.” (This copies only the files over to the new app, not the internal Git repository, so the version history is lost.)
  3. Test and update the development app in the Anvil IDE, committing changes as I go.
  4. Fetch the development app to my local production app Git repository from step #1.
  5. Graft the development app commits onto the tip of my local production app repository (using “git replace --graft”)
  6. Make the graft permanent using “git filter-branch,” which rewrites the development app commit ids. (I can no longer push back to the Anvil version of the development app, I think, so it will be discarded.)
  7. Fast-forward merge this development branch into master.
  8. Undo the changes to anvil.yaml (which otherwise causes an error like “cannot edit these data tables,” tracing from users.py)
  9. Push to origin, the production app on Anvil.

A post I found subsequently seems to suggest this (less involved but still clunky) alternative, after steps 1 and 2 as above:
3. Clone with Git my development app to a separate local repository.
4. For each commit to the development app, pull it down to my local development repository, copy the changed files to my local production app directory and commit the change to my local production app repository.
5. Repeat step 4 for each commit.
6. When ready to make a change to the live production app, push my local repository up to Anvil.

In a different place, meredydd speaks of “force-push,” which suggests:

  1. Clone with Git my “production app” onto my local machine.
  2. Create a clone of my production app within Anvil (via this) to serve as the “development app.” (This copies only the files over to the new app, not the internal Git repository, so the version history is lost.)
  3. Force push my local production app repository to the development app on Anvil, so it will have the full repository there now, restoring the version history. (This step is needed for step 4 to work smoothly. Caveat: I’m not clear on how the anvil.yaml issue discussed in the thread linked at top is resolved.)
  4. a) do code editing and commits locally, pushing to the development app on Anvil for testing; or b) edit the development app in the Anvil IDE, pulling new commits down to my local repository.
  5. Push the local repository to the production app on Anvil when ready.
1 Like