Best Version Control Options

That sounds like a good workflow. Once you’ve done the first 3 steps, it’s just

  • Push and pull as appropriate to sync local with cloud (step 4)
  • Push to Prod when you want to deploy (step 5)

And you could automate step 4 with a Bash script…

Here's a start on that
#!/bin/bash
##
# Anvil local repository watcher.
# Syncs with the cloud version of the app.
# Just commits; you need to add a push and a pull, but it's a start.
# Also, if you modify both the local and cloud version during the watch
# period, you might get merge conflicts. So don't do that.
#

# Where the app is checked out
APP_DIR="$1"
# The message to use for the autosave commits
AUTOSAVE_MESSAGE='Local autosave'
# How many seconds to wait between autosaves
WATCH_PERIOD=5

cd "$APP_DIR"

while true; do
  LAST_COMMIT_MESSAGE="$(git log -1 --pretty=%B)"
  if [[ "$LAST_COMMIT_MESSAGE" == "$AUTOSAVE_MESSAGE" ]] ; then
    # If the latest commit is an autosave, overwrite it.
    git commit -a --amend -m "$AUTOSAVE_MESSAGE"
  else
    # If the latest commit was done manually, make a new autosave commit.
    git commit -a -m "$AUTOSAVE_MESSAGE"
  fi
  sleep $WATCH_PERIOD
  echo "."
done

cd -
1 Like