Home
guest@avilabs.net ~$ man blog/obsidian-git-sync
Sync an Obsidian Vault with Git banner

Sync an Obsidian Vault with Git

Desktop: Obsidian Git plugin

  1. Open a terminal and run the following command to generate an SSH key:

    ssh-keygen -t ed25519

    Press Enter to accept the default file location.

  2. In the terminal, run the following command to display the public key, then copy the full output:

    cat ~/.ssh/id_ed25519.pub
  3. Sign in to GitHub and go to Profile picture → Settings → SSH and GPG keys → New SSH key. Enter a title, paste the public key into the Key field, and select Add SSH key.

  4. Return to the GitHub dashboard and select New to create a repository. Give it a name, set its visibility to Private, and create it.

  5. On the repository page, select Code → SSH, then copy the repository URL.

  6. In a terminal, go to the directory where you want to keep the vault and clone the repository:

    git clone <repository-url>
  7. Before opening the vault in Obsidian, create or update .gitignore in the cloned repository root and include:

    .DS_Store
    .trash/
    
    # Device-specific Obsidian state
    .obsidian/community-plugins.json
    .obsidian/workspace*.json
    
    # Installed plugin bundles; install plugins separately on each device
    .obsidian/plugins/*/main.js
    .obsidian/plugins/*/styles.css

    Commit and push .gitignore before setting up another device. If .obsidian/community-plugins.json was previously committed, remove it from tracking without deleting the local file:

    git rm --cached .obsidian/community-plugins.json
    git commit -m "Keep enabled Obsidian plugins device-specific"
    git push
  8. Install Obsidian, select Open folder as vault, and choose the cloned repository folder.

  9. In Obsidian, go to Settings → Community plugins, enable community plugins, and select Browse. Search for Git, install it, and enable it.

    The enabled-plugin list is device-local, so plugins must be enabled independently on each device.

  10. In the Settings sidebar, select Git and configure the following fields.

Automatic

  • Split timers for automatic commit and sync: Off
  • Auto commit-and-sync interval (minutes): 1
  • Auto commit-and-sync after stopping file edits: On
  • Auto commit-and-sync after latest commit: Off
  • Auto pull interval (minutes): 1
  • Auto commit-and-sync only staged files: Off

Pull

  • Merge strategy: Merge
  • Merge strategy on conflicts: None (git default)
  • Pull on startup: On

Commit-and-sync

  • Push on commit-and-sync: On
  • Pull on commit-and-sync: On

Mobile: GitSync app

  1. Install GitSync from your device’s app store.
  2. Open Auth, sign in to GitHub, and grant GitSync access to the vault repository.
  3. Open Clone and find the vault repository.
  4. Select the download icon beside the repository, choose Nested Clone, and select the folder where the vault should be stored.
  5. Open that folder as a vault in Obsidian.
  6. Enable the community plugins needed on mobile, but leave Obsidian Git disabled because GitSync handles mobile synchronization.
  7. In GitSync’s sync settings, add Obsidian as the linked app and enable sync when Obsidian opens and closes.

Keeping the enabled-plugin list device-local prevents mobile from disabling Obsidian Git on the desktop if the plugin fails to load on mobile.

Device-specific plugin state

Obsidian stores the list of enabled community plugins in .obsidian/community-plugins.json. Keep this file ignored because Obsidian may remove a plugin from the list when it fails to load on one device. If the list were shared, that change could disable the plugin on every other device after synchronization.

The installed plugin bundles (main.js and styles.css) are ignored, so each plugin must be installed and enabled separately on every device. Plugin configuration files under .obsidian/plugins/ remain shared unless explicitly ignored.

Note about one-minute desktop sync

The desktop Git plugin only runs while Obsidian is open. With Auto commit-and-sync after stopping file edits enabled, each new edit restarts the one-minute timer, so continuous editing can delay the commit and push. The one-minute pull interval also checks periodically rather than delivering phone changes instantly. Avoid editing the same note on both devices before they have finished syncing, as this can cause a Git conflict.

↑ Top