This guide describes how to set up an Obsidian vault that syncs across devices while maintaining a separate Git backup without interfering with the sync mechanism. This guide should work with either official Obsidian Sync solution or with unofficial sync plugins like Obsidian Livesync or Remotely Save.
- Git installed on your system
- Obsidian installed
- Either Obsidian Sync subscription or LiveSync plugin configured
- Basic familiarity with command line
# Create directories if they don't exist
mkdir -p ~/Documents/Vault.git # For Git repository
mkdir -p ~/Documents/Vault # For your vault# Initialize Git with separate directory
git init --separate-git-dir=$HOME/Documents/Vault.git ~/Documents/Vaultcd ~/Documents/Vault
# Backup existing .git directory
cp -r .git ~/Documents/Vault.git.backup
# Move Git directory to new location
mv .git ~/Documents/Vault.git
# Create gitfile pointing to new location
echo "gitdir: $HOME/Documents/Vault.git" > .gitCreate .gitignore file in your vault directory:
# Obsidian system files
.obsidian/cache/
.obsidian/workspace.json
.obsidian/workspace-mobile.json
.trash/
.DS_Store
# LiveSync Plugin (if using)
.obsidian/plugins/obsidian-livesync/data.json
.obsidian/plugins/obsidian-livesync/*.realm*
.obsidian/plugins/obsidian-livesync/realms/
# Obsidian Sync (if using)
.obsidian/sync.json
# Optionally, exclude all of obsidian settings from Git
# .obsidian/
# Optionally, exclude all of plugin settings from Git
# .obsidian/plugins
Add and commit .gitignore:
git add .gitignore
git commit -m "Add .gitignore for Obsidian"# Add your remote repository
git remote add origin <your-repository-url>
git branch -M main
git push -u origin main- Install obsidian-git plugin: https://github.com/Vinzent03/obsidian-git
- Then in plugin settings set desired Vault backup interval and Auto pull interval.
- Disable auto-pull on startup, because Obsidian Sync/Livesync also pulls on startup
- I recommend enabling this only on your main device to avoid potential conflicts
- Either enable official Obsidian Sync
- Or use one of the following plugins:
- Continue using Obsidian normally with sync enabled
- Git operations will work as usual from your vault directory
- All Git metadata is stored separately in
~/Documents/Vault.git - Your vault stays clean while maintaining version control
-
Multiple Devices: When setting up on additional devices:
# Clone the repository with separate Git dir git clone --separate-git-dir=$HOME/Documents/Vault.git <repository-url> ~/Documents/Vault
-
Checking Setup:
# Verify Git configuration cat ~/Documents/Vault/.git # Should show path to separate Git dir git status # Should work normally
-
Recovery:
- Obsidian sync/LiveSync handles day-to-day synchronization
- Git serves as a backup system and version control
- In case of sync issues, you can always fall back to Git
-
If Git commands don't work:
- Check if the gitfile path is correct
- Ensure the separate Git directory exists
- Verify permissions on both directories
-
If sync conflicts occur:
- Let Obsidian sync handle file conflicts
- Use Git for version control and recovery only
Thank you for the detailed tutorial.
In this case, do I only need to push the commit (from main device) and not pull from Git, in case of conflicts with the Sync plugin? I use LiveSync.