[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

How to check if it’s actually working?

# !!! manually restart termux !!!


git pull --rebase
Cannot pull with rebase: You have unstaged changes.
Please commit or stash them.
1 Like

It worked fine for a day then I once killed atermux accidently. When I started again it didn’t work. So I enabled it again, but it never worked again!!

Is it susceptible to such errors?
If I kill termux once, I need to uninstall the whole thing and reinstall again to get it to work?


It happened again. I had to fix it after reinstalling the Termux App.
Is there a way to start the cron task again if Termux is killed by mistake?

It’s a great idea to sync using Termux! I’ve been using MGit as my git client on Android for a while, though it is a manual process.

The advantage is I have more control on the synchronization, and won’t fail after a reboot or something that might kill the Termux app.

  1. “pkg install cronie termux-services” Command gives me “Unable to locate package termux-services”

  2. “sv-enable crond” = “The sv-enable is not installed. Install it by executing: pkg install termux-services”

  3. “pkg install termux-services” = “Unable to locate package termux-services”

  4. “crontab -e” = “The program crontab is not installed. Install it by executing: pkg install cronie”

  5. “pkg install cronie” = “Unable to locate package cronie”

I think termux-services is a second app altogether, if I remember correctly. Also, make sure you download Termux apps from Fdroid only. PlayStore versions are too old and won’t be updated as per Termux website.

Is there any update on how to fix these issues or an alternative way to sync android with GitHub?

I just use termux command line with no automation. Seems to work fine.

Unfortunately I’m sharing my vault, therefore it’s very unhandy when making changes and forgetting to push it / not updating fast enough

I found this If you installed termux from google playstore or a very old version, then you will receive package command errors. Playstore builds are deprecated and no longer supported. Package-Management

The Obsidian git plugin has since been updated with mobile support.