Syncing Obsidian Through Git

Back to Tangent's Shared Notes
(I am currently in danger of becoming homeless. If you can spare a few dollars, it would help a lot. PayPal.me/Guard13007)

Syncing Obsidian Through Git

Setting up Obsidian to sync through Git is fairly easy with desktop OSes, almost as easy with Android (though can cause some issues since virtualization is required by most guides), and requires a little more effort to set up on iOS (though the end result is extremely easy to use, quick, and effective).

Note that this requires a one-time purchase of Working Copy for $25 at time of writing. Unfortunately, the website and App Store both hide the purchase price completely, so I cannot know if this price is changed and update this note in the future. Isn't that just grand?

  1. Megan Sullivan's guide for iOS is a little outdated, but will get you there with minimal deviation.
    • For deviations, consult Working Copy's Users' guide.
    • Warning: When setting up automated push, always pull immediately before a push. I have experienced data loss before I modified my shortcut to do this.
  2. When setting up obsidian-git, there are a few known common issues. If they are encountered, look for a solution there first.
  3. To make authentication easier on macOS, install Git Credential Mananger.
    • (That same link has instructions for other platforms if you scroll up to the top and select a different platform.)

Android

This guide is outdated, as obsidian-git apparently works natively on mobile devices now. I haven't intentionally tried it, and last I had it open on a mobile device, it created some weird errors, so I don't believe this yet.

  • If obsidian-git doesn't work, it will initially try to do things on its own and cause errors. If it is not working, go to the settings for it and disable it on the device in order to prevent issues. (This toggle is per-device, so it won't affect usage elsewhere.)

The following is based on RedeyeFR's guide, which has some errors and missing information.

termux-setup-storage  # enables access back and forth between Termux and the root file system under ~/storage/shared
pkg update -y         # make sure Termux packages are up-to-date
pkg upgrade -y
pkg install git gh
gh auth login
git config --global user.name "name"
git config --global user.email "email"
cd ~/storage/shared
git clone https://github.com/TangentFoxy/Block-Four  # obviously, replace with your own repo

# I am skipping all of the crontab nonsense

# any time you need to sync, the following commands will do it:
git pull && git add -A && git commit -a -m "android vault backup: `date +'%Y-%m-%d %H-%M-%S'`" && git push

(Notice that the "sync command" includes a pull command before pushing changes. I do not know if this is strictly necessary, but Working Copy destroyed data before I made it always pull before push, so I assume the same error can occur here.)

Share Note for Obsidian 🌓