git clone https://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@github.com//bartdurak/mud_gra.git
````
I recently started using Obsidian and didn’t want to pay for Sync or Working Copy, so I thought I’d try to figure out a way to sync my vault everywhere for free. I saw in the comments of this post by rsteele 98 and this post from ForceBru 83 that people were able to get GitHub to sync with their iOS device using the a-shell app, but the way to do it was not really discussed. I hope that this tutorial will be useful for other non-tech-savvy people like myself who would like to get their vault synced across all their devices without having to pay for it. The overall process for this comes from this post on the Logseq forums 100. It’s somewhat involved, but has improved my workflow so I think it’s worthwhile.
Process
Set-up:
- Install the a-shell app from the app store (link 886)
- Install the Obsidian mobile app
- Open a-shell and run
pickFolder - When the pop-up opens select On my iPhone → Obsidian (hit ‘Done’) choose the entire folder
- The working directory should now be the Obsidian files folder. For me, a-shell auto-named the the folder
Documents(different from the default/Documents), so runrenamemark Documents obsidianto change it - Verify that the obsidian folder is a bookmark by running
showmarks
Generate/Pair SSH key:
- Follow the steps from this GitHub article 615 to generate an SSH key (skip the other sections)
- To get the public key,
cdback to root thencd .ssh/andhead id_ed25519.pub - Copy the entire output of the file (including the e-mail part)
- Sign in to Github in your mobile browser of choice (couldn’t see a way to add it through the app) and go to Settings → SSH and GPG keys → New SSH key
- Name the device and paste the contents of the
.pubkey into the field.
Create local repo:
- Go back to the obsidian folder with
jump obsidian - Create a subfolder for your vault with
mkdir VAULT-NAME, then do the following commands to clone your vault:cd VAULT-NAMElg2 init .lg2 remote add origin git@github.com:USERNAME/REPO-NAME.gitlg2 pull origin
- Type
yat the prompt to add the host/key pair - Choose SSH key
1and enter its password (just hit enter if you didn’t add a password) - Your vault should be downloaded from GitHub! Now is a good time to go into the Obsidian app and check to make sure everything looks okay. The Obsidian Git plugin throws a bunch of errors on startup, so go to Settings → Community Plugins → Obsidian Git settings and turn on ‘Disable on this device’
- Back in a-shell, at the beginning of the last output a-shell says
Consider running.... Copy and run the two commands its suggests to store the SSH key and its password inuser.identityFileanduser.password, respectively - Then store the name and email used for commits with the commands
lg2 config user.name "NAME"lg2 config user.email "EMAIL"
Define Shortcuts to push and pull:
Both Shortcuts execute shell scripts through the a-shell Shortcut command ‘Execute command’. Links to my Shortcuts are below; all they do is execute the following commands inside a-shell:
- Pull Shortcut (Link 569):
jump obsidiancd VAULT-NAMElg2 pull origin
- Push Shortcut (Link 409):
jump obsidiancd VAULT-NAMElg2 add .lg2 commit -m "updating from phone"lg2 push origin
Automate push/pull:
- For pulling:
- To automate pulling from GitHub on startup, I created another Shortcut (link 345) that would call the ‘Obsidian pull’ shortcut (created in the last step) and then open the Obsidian app
- Add this Shortcut to the home screen to replace Obsidian (app icon link 215)
- Optionally, disable Obsidian from appearing in the search menu (Settings → Obsidian → Siri & Search → Show App in Search) so that this shortcut is the only way to launch it
- For pushing:
- This one is a little more tricky. I created Shortcut Automations that trigger whenever the Obsidian app is open or closed, then waits two minutes before pushing. If the app is closed and re-opened within two minutes the push doesn’t go through. A link to the Shortcut that triggers when Obsidian is closed is here 239, and a link to the Shortcut that triggers when Obsidian is opened is here 173. (If the Shortcuts folder doesn’t exist in Files, you’ll have to create it.) A downside to this method is that locking the phone with Obsidian still running doesn’t trigger a push, as iOS still considers the app ‘open’. Additionally, while working in the app for a long time, a push is never triggered. If anyone has any better ideas about how best how/when to push please let me know.
Other notes
- I started learning how to use the shell and git about two weeks ago (and just to start synchronising my vault across devices), so I apologise if some of the steps are clunky or inefficient.
- I’m pretty new to Obsidian as well and my vault is pretty small. The pushing/pulling might be too slow to be used reliably on larger vaults.
- I tried using Automations to run the push/pull Shortcuts directly when Obsidian is open or closed, but they run whenever the app is minimised or un-minimised, which became cumbersome quickly.
- Opening the app through a Shortcut that pulls from GitHub then launches Obsidian has worked pretty well so far for me, but I would like to have a better way to push.