Skip to main content

.stignore Syntax and Patterns

The .stignore file tells Syncthing which files and directories to exclude from syncing in a given folder. It is placed in the root of the synced folder and follows a glob-based pattern syntax.

Learning Focus

.stignore is per-folder and per-device. Each device can have its own .stignore — one device may ignore cache files while another may not. Understand global vs device-specific ignore rules.

Core Idea

Patterns in .stignore match against paths relative to the synced folder root. A pattern without a / can match at any depth. A pattern starting with / only matches the folder root.

File Location

/var/www/html/uploads/
├── .stignore ← Place here (folder root)
├── images/
└── cache/

The .stignore file itself is synced to all peers unless you ignore it. This means ignore rules can be shared globally (one .stignore for all peers) or kept local using the #include directive.

Basic Syntax

.stignore
# This is a comment
# Lines starting with # are ignored

# Ignore a specific file
secret.txt

# Ignore a file type anywhere in the folder tree
*.log
*.tmp
*.cache

# Ignore a specific directory
node_modules

# Ignore a path relative to the folder root (leading slash = absolute)
/cache

# Ignore all .txt files in a specific subdirectory
/docs/*.txt

Special Markers

MarkerMeaning
//Two forward slashes = rest of line is a comment
!Negate the following pattern (un-ignore)
(?i)Make the following pattern case-insensitive
#include <file>Include patterns from another file

Pattern Rules

PatternWhat it matches
*.logAny .log file at any depth
/*.log.log files only in the root of the folder
logs/Any directory named logs at any depth
/logs/A directory named logs only at the root
foo/**Everything inside foo/ recursively
?Any single character (not path separator)
[abc]Any single character from the set
[!abc]Any character NOT in the set

Working Examples

Ignore build artifacts and caches

.stignore — development project
# Node.js
node_modules/
.npm/
dist/
build/

# Python
__pycache__/
*.pyc
*.pyo
.venv/
.env

# General
*.log
*.tmp
*.bak
*.swp
.DS_Store
Thumbs.db

Ignore temp files for common applications

.stignore — office and productivity
# LibreOffice lock files
.~lock.*

# Microsoft Office temp files
~$*.docx
~$*.xlsx
~$*.pptx

# Vim swap files
*.swp
*.swo

# JetBrains IDE
.idea/

# VS Code local settings
.vscode/

WordPress / PHP server folder

.stignore — WordPress
# WordPress cache plugins
/wp-content/cache/
/wp-content/upgrade/

# Object cache
/wp-content/object-cache.php

# SQLite (if using WP SQLite plugin)
*.db-wal
*.db-shm

# Debug log
/wp-content/debug.log

# Uploads cache (if a CDN handles delivery)
/wp-content/uploads/cache/

The #include Directive: Device-Specific Rules

The .stignore file is normally synced to all peers. If you want some rules to be local only (not shared with peers), use #include:

.stignore (root file — synced to all peers)
// Global rules for everyone
*.log

// Pull in local device-specific rules (NOT synced)
#include .stignore-local

Then create .stignore-local on each device (add it to .stignore so it's not synced):

.stignore
.stignore-local

Negation Patterns

You can un-ignore something with !:

# Ignore all log files
*.log

# But keep error.log
!error.log
note

Order matters. Rules are evaluated top-to-bottom. Put your negation patterns after the rule they override.

Case-Insensitive Matching

On Linux (case-sensitive filesystem), use (?i) to match regardless of case:

# Ignore Thumbs.db case-insensitively (handles THUMBS.DB, thumbs.db, etc.)
(?i)thumbs.db
(?i).DS_Store

What's Next