Originally posted on Discord here.
This set of steps is very rough and may not work for everyone. I may not be able to help if it doesn’t work, so apologies in advance if that’s the case!
How to autosync a git repo vault on Android:
This tutorial will assume you’ve already got a vault as a git repo using something like MGit to sync. If you’re wondering how to set this up, the friendly folk on Discord can probably lend a hand.
- Download Termux (a terminal app for Android)
- Open it and type the following commands:
pkg install cronie termux-services # !!! manually restart termux !!! sv-enable crond crontab -e
- The third command will open a text editor like Nano. To sync your vault every 10 minutes just enter this (and adjust the folder & branch names as needed):
*/10 * * * * cd /storage/emulated/0/Documents/Obsidian/zettelkasten && git pull --rebase && git add --all && git commit -m "zettelkasten" && git push origin master
- Save the file. If it’s using Nano like on my phone, to save a file it’s just CTRL + O then CTRL + X, using the CTRL button in the app
- Note that you will need to have git credentials saved already, I think I did this by typing
git config --global credential.helper storeand then pushing manually and entering my username + password
I did this a couple months ago and it’s worked without hiccups since. It has no noticeable impact on battery life too. If anyone comes up with ways to simplify this method or any errors in the steps, I’m all ears!