Skip to main content

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

Learning Focus

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

SyntaxBehaviour
filenameMatches filename in any directory
dirname/Matches the directory dirname and all its contents
*.extMatches any file ending in .ext
**Matches any number of directories (recursively)
/patternMatches only in the folder root (anchored)
!/patternNegation — include this even if a previous rule excludes it
(?i)patternCase-insensitive match
(?d)patternDelete on the remote even if ignored — use with caution
#include filenameInclude patterns from another file in the same directory
// commentComment line (double slash)
warning

Order matters. Rules are evaluated top to bottom. A negation rule (!) must come after the exclusion rule it overrides.

Full Pattern Reference

.stignore — full 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
warning

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:

.stignore (root)
// Main ignores
*.tmp
*.log

// Include shared patterns from a central file
#include shared-ignores.txt
shared-ignores.txt (same directory)
node_modules/
.DS_Store
*.swp
note

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

test-ignore-pattern.sh
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-PatternProblemCorrect Approach
* (exclude everything)Nothing syncsOnly ever use * with a negation block below it
/tmpOn Linux, /tmp is not inside your sync folder — pattern has no effectUse tmp/ (relative to folder root)
*.log but not logs/Only excludes .log files in root, not in subdirsUse **/*.log or just *.log (which matches recursively)
Ignoring .stversions with (?d)Versions deleted on remote peersNever apply (?d) to .stversions
Putting secrets in .stignore itself.stignore is synced — comments in it are visible to allStore secrets outside the sync folder entirely

Syncthing vs gitignore Differences

Featuregitignore.stignore
Recursive * glob**** (same)
Anchoring to rootLeading /Leading / (same)
Negation!pattern!pattern (same)
Case-insensitiveNot supported(?i)pattern
Delete on remoteNot applicable(?d)pattern
Include other filesNot 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: