[mobile] How to sync vaults with Git on Android

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.

  1. Download Termux (a terminal app for Android)
  2. Open it and type the following commands:
pkg install cronie termux-services
# !!! manually restart termux !!!
sv-enable crond
crontab -e
  1. 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
  1. 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
  2. Note that you will need to have git credentials saved already, I think I did this by typing git config --global credential.helper store and 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!


Getting error for following command
sv-enable crond
fail: crond: unable to change to service directory: file does not exist