.stignore Patterns Reference
.stignore uses a gitignore-compatible syntax with a few Syncthing-specific extensions. This reference consolidates the full pattern language, common pattern libraries, and anti-patterns.
Always test patterns with the REST API before committing them. An overly broad pattern silently excludes files — you will not get an error, the files simply stop syncing.
Pattern Syntax Rules
| Syntax | Behaviour |
|---|---|
filename | Matches filename in any directory |
dirname/ | Matches the directory dirname and all its contents |
*.ext | Matches any file ending in .ext |
** | Matches any number of directories (recursively) |
/pattern | Matches only in the folder root (anchored) |
!/pattern | Negation — include this even if a previous rule excludes it |
(?i)pattern | Case-insensitive match |
(?d)pattern | Delete on the remote even if ignored — use with caution |
#include filename | Include patterns from another file in the same directory |
// comment | Comment line (double slash) |
Order matters. Rules are evaluated top to bottom. A negation rule (!) must come after the exclusion rule it overrides.
Full Pattern Reference
// ============================================================
// OS-Generated Files
// ============================================================
// macOS
.DS_Store
.AppleDouble
.LSOverride
._*
.Spotlight-V100
.Trashes
// Windows
Thumbs.db
ehthumbs.db
desktop.ini
$RECYCLE.BIN/
// Linux
.Trash-*
.nfs*
// ============================================================
// Editor and IDE
// ============================================================
// JetBrains (IntelliJ, PhpStorm, GoLand, etc.)
.idea/
*.iml
*.ipr
*.iws
// Visual Studio Code
.vscode/
*.code-workspace
// Vim / Neovim
*.swp
*.swo
*~
.vim/
// Emacs
\#*\#
.\#*
// ============================================================
// Development Artifacts
// ============================================================
// Node.js
node_modules/
npm-debug.log*
yarn-debug.log*
yarn-error.log*
// Python
__pycache__/
*.pyc
*.pyo
*.pyd
.Python
.env
.venv
venv/
*.egg-info/
dist/
build/
.pytest_cache/
.mypy_cache/
// Go
vendor/
// PHP / Composer
/vendor/
composer.lock
// Ruby
/log/
/tmp/
.bundle/
// Rust
/target/
// Java / Gradle / Maven
.gradle/
build/
target/
*.class
// ============================================================
// Logs and Temporary Files
// ============================================================
*.log
*.log.*
*.tmp
*.temp
*.bak
*.old
*.cache
// ============================================================
// Docker and DevOps
// ============================================================
.docker/
*.env
.env.local
.env.production
docker-compose.override.yml
// ============================================================
// Security — NEVER sync these
// ============================================================
*.key
*.pem
*.p12
*.pfx
id_rsa
id_ed25519
.ssh/
.gnupg/
.netrc
secrets.yml
secrets.yaml
// ============================================================
// Large Binary / Media (optional — uncomment if needed)
// ============================================================
// *.iso
// *.mov
// *.mp4
// *.mkv
// *.avi
// *.dmg
// *.pkg
// ============================================================
// Syncthing Internal Files (always ignore)
// ============================================================
.stfolder
.stversions
Negation Patterns
Use ! to re-include something after a broad exclusion:
// Exclude all .env files
*.env
// But re-include the shared (non-secret) one
!.env.example
!.env.shared
Negation only works to undo a previous exclusion. You cannot use ! to force-sync a file that is excluded by a parent directory rule.
Case-Insensitive Matching
On Linux (case-sensitive filesystem), use (?i) to match Windows/macOS files that may differ in case:
(?i)thumbs.db
(?i)desktop.ini
(?i)*.JPG
Including Pattern Files
Split large .stignore files using #include:
// Main ignores
*.tmp
*.log
// Include shared patterns from a central file
#include shared-ignores.txt
node_modules/
.DS_Store
*.swp
The included file must be in the same directory as the .stignore that references it. The included file is not itself subject to sync (.stignore ignores itself by default).
Testing Patterns via REST API
STKEY="your-api-key"
CERT="$HOME/.local/share/syncthing/https-cert.pem"
FOLDER="docs-sync"
# View current effective ignore rules
curl -fs -H "X-API-Key: $STKEY" \
"https://localhost:8384/rest/db/ignores?folder=$FOLDER" \
--cacert "$CERT" | jq '.ignore[]'
# After editing .stignore, apply without restarting
curl -fs -X POST \
-H "X-API-Key: $STKEY" \
-H "Content-Type: application/json" \
-d '{"ignore": ["*.tmp", "node_modules/"]}' \
"https://localhost:8384/rest/db/ignores?folder=$FOLDER" \
--cacert "$CERT"
Anti-Patterns to Avoid
| Anti-Pattern | Problem | Correct Approach |
|---|---|---|
* (exclude everything) | Nothing syncs | Only ever use * with a negation block below it |
/tmp | On Linux, /tmp is not inside your sync folder — pattern has no effect | Use tmp/ (relative to folder root) |
*.log but not logs/ | Only excludes .log files in root, not in subdirs | Use **/*.log or just *.log (which matches recursively) |
Ignoring .stversions with (?d) | Versions deleted on remote peers | Never apply (?d) to .stversions |
Putting secrets in .stignore itself | .stignore is synced — comments in it are visible to all | Store secrets outside the sync folder entirely |
Syncthing vs gitignore Differences
| Feature | gitignore | .stignore |
|---|---|---|
Recursive * glob | ** | ** (same) |
| Anchoring to root | Leading / | Leading / (same) |
| Negation | !pattern | !pattern (same) |
| Case-insensitive | Not supported | (?i)pattern |
| Delete on remote | Not applicable | (?d)pattern |
| Include other files | Not supported natively | #include filename |
| Comments | # | // |
What's Next
You've completed the full Syncthing learning track! 🎉
Review your knowledge:
Or go back to the beginning: