Connections to this page

Keeping a Working Copy git repo synchronized with Shortcuts

Published Feb 23, 2023

Since publishing my notes required pushing them to a Git repo anyway, I set up a git server on my VPS and have been keeping my entire main Obsidian vault synced via git, too.

The basic idea is this: whenever I launch or go away from Obsidian, I want my notes synced up. So, I’ve tied automations on macOS and iOS to trigger a commit - pull - push every time the app is focused or unfocused.

On macOS, there’re numerous ways of doing this. On iOS, however, the only option is Working Copy, a wonderful app for git. Working Copy offers a fancy “mirror folder structure” feature that you can use to keep a git repo in it mirrored into your On My iPhone/Obsidian folder. There’s a great guide to getting this set up on the forum. However, once you’ve got it set up, you’ve still gotta manually invoke all of the git actions necessary to keep your local files up to date with the remote.

Fortunately, Working Copy offers excellent Shortcuts support, and you can use tie Shortcuts actions to other triggers via Shorcuts’s Automation tab. For instance, you can make a Shorcut trigger every time you open or close Obsidian.

So, I created three utility Shortcuts (for commit/push/pull) and one “Sync vault” shortcut that brings them all together, and I created an Automation that triggers that Sync Vault shortcut every time Obsidian is opened or closed.

Here’re the Shortcuts:

It helpfully summarizes the changes in a notification every time it runs.

Related: