Syncing Obsidian vaults with Git works great until machine-specific files create conflicts or you accidentally commit sensitive notes. This guide gives you two battle-tested .gitignore configurations and a safety checklist to avoid common pitfalls.

Quick take: Use the Strict setup to eliminate config conflicts entirely. Add .gitattributes for cleaner diffs. Keep your repo private unless you’re building a public knowledge base.


A) Minimal (Keep plugin settings, drop noise)

Keeps plugin settings and config across devices. Excludes cache and workspace files.

# OS and editor clutter
.DS_Store
._*
Thumbs.db
ehthumbs.db
Icon?
.Spotlight-V100
.Trashes
*.swp
*.swo
*.tmp

# Obsidian
.trash/
.obsidian/cache/
.obsidian/workspace*
.obsidian/updates.json

# Common plugin caches
.obsidian/plugins/*/cache/
.obsidian/plugins/*/.cache/
.obsidian/plugins/*/node_modules/

B) Strict (Zero config conflicts)

Excludes all .obsidian/ config. No merge conflicts, ever. Set up plugins once per device.

# OS and editor clutter
.DS_Store
._*
Thumbs.db
ehthumbs.db
Icon?
.Spotlight-V100
.Trashes
*.swp
*.swo
*.tmp

# Obsidian - exclude all configuration
.obsidian/
.trash/

Add this to get better diffs and prevent line-ending issues:

# Ensure consistent line endings
* text=auto
*.md text

# Treat binary files properly
*.png binary
*.jpg binary
*.jpeg binary
*.gif binary
*.pdf binary

Safety Checklist

  1. Keep your repo private - Your notes likely contain personal information
  2. Review before first commit - Run git status and git diff to verify what you’re committing
  3. Scan for sensitive data - Check for API keys, passwords, or private details
  4. Test on a clone first - Clone to a temp folder and verify the workflow before syncing devices
  5. Write meaningful commits - “Updated notes” helps no one. “Added project planning docs” helps future you

Basic Sync Workflow

# Pull changes from other devices
git pull

# Stage and commit your changes
git add .
git commit -m "Update notes from [device name]"

# Push to GitHub
git push

For automatic syncing, consider using Git plugins like Obsidian Git that can auto-commit and push at regular intervals.