Skip to content

Instantly share code, notes, and snippets.

@saikotek
Last active October 19, 2025 04:44
Show Gist options
  • Select an option

  • Save saikotek/a590810d0d60ad41c3b0750270d22394 to your computer and use it in GitHub Desktop.

Select an option

Save saikotek/a590810d0d60ad41c3b0750270d22394 to your computer and use it in GitHub Desktop.
Easy setup Obsidian Sync (or Livesync or Remotely Save) with Git

Setting Up Obsidian Sync (or Livesync or Remotely Save) with Separate Git Backup

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.

Prerequisites

  • Git installed on your system
  • Obsidian installed
  • Either Obsidian Sync subscription or LiveSync plugin configured
  • Basic familiarity with command line

Setup Steps

1. Initial Setup

# Create directories if they don't exist
mkdir -p ~/Documents/Vault.git  # For Git repository
mkdir -p ~/Documents/Vault     # For your vault

2. Git Configuration

For a New Vault:

# Initialize Git with separate directory
git init --separate-git-dir=$HOME/Documents/Vault.git ~/Documents/Vault

For an Existing Vault with Git:

cd ~/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" > .git

3. Git Ignore Configuration

Create .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"

4. Configure Remote Repository

# Add your remote repository
git remote add origin <your-repository-url>
git branch -M main
git push -u origin main

5. Setup Automated Backups (Optional)

  • 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

6. Setup your Sync solution

  • Either enable official Obsidian Sync
  • Or use one of the following plugins:
    • Obsidian LiveSync (quick guide here)
    • Remotely Save (usage guides here)

Usage

  • 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

Additional Tips

  1. 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
  2. Checking Setup:

    # Verify Git configuration
    cat ~/Documents/Vault/.git  # Should show path to separate Git dir
    git status  # Should work normally
  3. 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

Troubleshooting

  1. If Git commands don't work:

    • Check if the gitfile path is correct
    • Ensure the separate Git directory exists
    • Verify permissions on both directories
  2. If sync conflicts occur:

    • Let Obsidian sync handle file conflicts
    • Use Git for version control and recovery only
@AlFirous
Copy link

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment