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.
Recommended .gitignore
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/
Recommended .gitattributes
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
- Keep your repo private - Your notes likely contain personal information
- Review before first commit - Run
git statusandgit diffto verify what you’re committing - Scan for sensitive data - Check for API keys, passwords, or private details
- Test on a clone first - Clone to a temp folder and verify the workflow before syncing devices
- 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.