Skip to content

Instantly share code, notes, and snippets.

@saikotek
Last active March 7, 2026 06:49
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 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.

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
.trash/

# 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

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)

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

Remember to regularly verify that both sync and Git backup are working as expected by checking the sync status in Obsidian and running git status periodically.

@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