1SYNCTHING-STIGNORE(5) Syncthing SYNCTHING-STIGNORE(5)
2
3
4
6 syncthing-stignore - Prevent files from being synchronized to other
7 nodes
8
10 .stignore
11
13 If some files should not be synchronized to (or from) other devices, a
14 file called .stignore can be created containing file patterns to ig‐
15 nore. The .stignore file must be placed in the root of the folder. The
16 .stignore file itself will never be synced to other devices, although
17 it can #include files that are synchronized between devices. All pat‐
18 terns are relative to the folder root. The contents of the .stignore
19 file must be UTF-8 encoded.
20
21 NOTE:
22 Note that ignored files can block removal of an otherwise empty di‐
23 rectory. See below for the (?d) prefix to allow deletion of ignored
24 files.
25
27 The .stignore file contains a list of file or path patterns. The first
28 pattern that matches will decide the fate of a given file.
29
30 • Regular file names match themselves, i.e. the pattern foo matches the
31 files foo, subdir/foo as well as any directory named foo. Spaces are
32 treated as regular characters, except for leading and trailing spa‐
33 ces, which are automatically trimmed.
34
35 • Asterisk (*) matches zero or more characters in a filename, but does
36 not match the directory separator. te*ne matches telephone, sub‐
37 dir/telephone but not tele/phone.
38
39 • Double asterisk (**) matches as above, but also directory separators.
40 te**ne matches telephone, subdir/telephone and tele/sub/dir/phone.
41
42 • Question mark (?) matches a single character that is not the direc‐
43 tory separator. te??st matches tebest but not teb/st or test.
44
45 • Square brackets ([]) denote a character range: [a-z] matches any
46 lower case character.
47
48 • Curly brackets ({}) denote a set of comma separated alternatives:
49 {banana,pineapple} matches either banana or pineapple.
50
51 • Backslash (\) “escapes” a special character so that it loses its spe‐
52 cial meaning. For example, \{banana\} matches {banana} exactly and
53 does not denote a set of alternatives as above. Escaped characters
54 are not supported on Windows.
55
56 • A pattern beginning with / matches in the root of the folder only.
57 /foo matches foo but not subdir/foo.
58
59 • A pattern beginning with #include results in loading patterns from
60 the named file. It is an error for a file to not exist or be included
61 more than once. Note that while this can be used to include patterns
62 from a file in a subdirectory, the patterns themselves are still rel‐
63 ative to the folder root. Example: #include more-patterns.txt.
64
65 • A pattern beginning with a ! prefix negates the pattern: matching
66 files are included (that is, not ignored). This can be used to over‐
67 ride more general patterns that follow.
68
69 • A pattern beginning with a (?i) prefix enables case-insensitive pat‐
70 tern matching. (?i)test matches test, TEST and tEsT. The (?i) prefix
71 can be combined with other patterns, for example the pattern
72 (?i)!picture*.png indicates that Picture1.PNG should be synchronized.
73 On Mac OS and Windows, patterns are always case-insensitive.
74
75 • A pattern beginning with a (?d) prefix enables removal of these files
76 if they are preventing directory deletion. This prefix should be used
77 by any OS generated files which you are happy to be removed.
78
79 • A line beginning with // is a comment and has no effect.
80
81 NOTE:
82 Prefixes can be specified in any order (e.g. “(?d)(?i)”), but cannot
83 be in a single pair of parentheses (not “(?di)”).
84
85 NOTE:
86 Include patterns (that begin with !) cause Syncthing to traverse the
87 entire directory tree regardless of other ignore patterns. If the
88 watcher is enabled, the entire directory tree will be watched as
89 well.
90
91 Top-level include patterns are treated as special cases and will not
92 force Syncthing to scan (or watch) the entire directory tree. For
93 example: !/foo is a top-level include pattern, while !/foo/bar is
94 not.
95
97 Given a directory layout:
98
99 .DS_Store
100 foo
101 foofoo
102 bar/
103 baz
104 quux
105 quuz
106 bar2/
107 baz
108 frobble
109 My Pictures/
110 Img15.PNG
111
112 and an .stignore file with the contents:
113
114 (?d).DS_Store
115 !frobble
116 !quuz
117 foo
118 *2
119 qu*
120 (?i)my pictures
121
122 all files and directories called “foo”, ending in a “2” or starting
123 with “qu” will be ignored. The end result becomes:
124
125 .DS_Store # ignored, will be deleted if gets in the way of parent directory removal
126 foo # ignored, matches "foo"
127 foofoo # synced, does not match "foo" but would match "foo*" or "*foo"
128 bar/ # synced
129 baz # synced
130 quux # ignored, matches "qu*"
131 quuz # synced, matches "qu*" but is excluded by the preceding "!quuz"
132 bar2/ # synced, despite matching "*2" due to child frobble
133 baz # ignored, due to parent being ignored
134 frobble # synced, due to "!frobble"
135 My Pictures/ # ignored, matched case insensitive "(?i)my pictures" pattern
136 Img15.PNG # ignored, due to parent being ignored
137
138 NOTE:
139 Please note that directory patterns ending with a slash some/direc‐
140 tory/ matches the content of the directory, but not the directory
141 itself. If you want the pattern to match the directory and its con‐
142 tent, make sure it does not have a / at the end of the pattern.
143
145 The Syncthing Authors
146
148 2014-2019, The Syncthing Authors
149
150
151
152
153v1 Oct 17, 2021 SYNCTHING-STIGNORE(5)