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 other devices, a file
14 called .stignore can be created containing file patterns to ignore. The
15 .stignore file must be placed in the root of the folder. The .stignore
16 file itself will never be synced to other devices, although it can
17 #include files that are synchronized between devices. All patterns are
18 relative to the folder root.
19
20 NOTE:
21 Note that ignored files can block removal of an otherwise empty
22 directory. See below for the (?d) prefix to allow deletion of
23 ignored files.
24
26 The .stignore file contains a list of file or path patterns. The first
27 pattern that matches will decide the fate of a given file.
28
29 · Regular file names match themselves, i.e. the pattern foo matches the
30 files foo, subdir/foo as well as any directory named foo. Spaces are
31 treated as regular characters.
32
33 · Asterisk matches zero or more characters in a filename, but does not
34 match the directory separator. te*st matches test, subdir/telerest
35 but not tele/rest.
36
37 · Double asterisk matches as above, but also directory separators.
38 te**st matches test, subdir/telerest and tele/sub/dir/rest.
39
40 · Question mark matches a single character that is not the directory
41 separator. te??st matches tebest but not teb/st or test.
42
43 · Characters enclosed in square brackets [] are interpreted as a char‐
44 acter range [a-z]. Before using this syntax you should have a basic
45 understanding of regular expression character classes.
46
47 · A pattern beginning with / matches in the current directory only.
48 /foo matches foo but not subdir/foo.
49
50 · A pattern beginning with #include results in loading patterns from
51 the named file. It is an error for a file to not exist or be included
52 more than once. Note that while this can be used to include patterns
53 from a file in a subdirectory, the patterns themselves are still rel‐
54 ative to the folder root. Example: #include more-patterns.txt.
55
56 · A pattern beginning with a ! prefix negates the pattern: matching
57 files are included (that is, not ignored). This can be used to over‐
58 ride more general patterns that follow.
59
60 · A pattern beginning with a (?i) prefix enables case-insensitive pat‐
61 tern matching. (?i)test matches test, TEST and tEsT. The (?i) prefix
62 can be combined with other patterns, for example the pattern
63 (?i)!picture*.png indicates that Picture1.PNG should be synchronized.
64 On Mac OS and Windows, patterns are always case-insensitive.
65
66 · A pattern beginning with a (?d) prefix enables removal of these files
67 if they are preventing directory deletion. This prefix should be used
68 by any OS generated files which you are happy to be removed.
69
70 · A line beginning with // is a comment and has no effect.
71
72 · Windows does not support escaping \[foo - bar\].
73
74 NOTE:
75 Prefixes can be specified in any order (e.g. “(?d)(?i)”), but cannot
76 be in a single pair of parentheses (not “(?di)”).
77
79 Given a directory layout:
80
81 .DS_Store
82 foo
83 foofoo
84 bar/
85 baz
86 quux
87 quuz
88 bar2/
89 baz
90 frobble
91 My Pictures/
92 Img15.PNG
93
94 and an .stignore file with the contents:
95
96 (?d).DS_Store
97 !frobble
98 !quuz
99 foo
100 *2
101 qu*
102 (?i)my pictures
103
104 all files and directories called “foo”, ending in a “2” or starting
105 with “qu” will be ignored. The end result becomes:
106
107 .DS_Store # ignored, will be deleted if gets in the way of parent directory removal
108 foo # ignored, matches "foo"
109 foofoo # synced, does not match "foo" but would match "foo*" or "*foo"
110 bar/ # synced
111 baz # synced
112 quux # ignored, matches "qu*"
113 quuz # synced, matches "qu*" but is excluded by the preceding "!quuz"
114 bar2/ # ignored, matched "*2"
115 baz # ignored, due to parent being ignored
116 frobble # ignored, due to parent being ignored; "!frobble" doesn't help
117 My Pictures/ # ignored, matched case insensitive "(?i)my pictures" pattern
118 Img15.PNG # ignored, due to parent being ignored
119
120 NOTE:
121 Please note that directory patterns ending with a slash some/direc‐
122 tory/ matches the content of the directory, but not the directory
123 itself. If you want the pattern to match the directory and its con‐
124 tent, make sure it does not have a / at the end of the pattern.
125
127 Currently the effects on who is in sync with what can be a bit confus‐
128 ing when using ignore patterns. This should be cleared up in a future
129 version…
130
131 Assume two devices, Alice and Bob, where Alice has 100 files to share,
132 but Bob ignores 25 of these. From Alice’s point of view Bob will become
133 about 75% in sync (the actual number depends on the sizes of the indi‐
134 vidual files) and remain in “Syncing” state even though it is in fact
135 not syncing anything (issue #623 <https://github.com/syncthing/sync‐
136 thing/issues/623>). From Bob’s point of view, it’s 100% up to date but
137 will show fewer files in both the local and global view.
138
139 If Bob adds files that have already been synced to the ignore list,
140 they will remain in the “global” view but disappear from the “local”
141 view. The end result is more files in the global folder than in the
142 local, but still 100% in sync (issue #624 <https://github.com/sync‐
143 thing/syncthing/issues/624>). From Alice’s point of view, Bob will
144 remain 100% in sync until the next reconnect, because Bob has already
145 announced that he has the files that are now suddenly ignored.
146
148 The Syncthing Authors
149
151 2014-2019, The Syncthing Authors
152
153
154
155
156v1 Apr 13, 2019 SYNCTHING-STIGNORE(5)