The Ignoring Files section of the documentation is well written and covers everything concisely, and the patterns are clearly explained, but I needed to study the documentation for quite a long time before I grasped the matching process and the resulting effects on each file or directory. The following understanding developed in my mind, and has made it much easier for me to craft a .stignore file. I’m posting for confirmation or correction of my understanding, and also to share with others who may find this helpful (assuming it’s correct).
How does Syncthing determine the disposition of an examined file or directory?
Each item (file or directory) examined** by Syncthing is compared to the .stignore pattern list, starting from the top of the pattern list and working down. The first pattern to match an item determines that item’s disposition (either ignored or included). Any remaining patterns become irrelevant to the disposition of that item. If no patterns match, the item receives an ‘included’ disposition.
**Not all files are examined by Syncthing. See step 2 below.
When examining files and directories, in what order does Syncthing move through the file structure?
1. Syncthing examines all the root files and directories and determines a disposition for each.
2. Syncthing descends one level into each directory and examines the files and directories at that level, determining a disposition for each. Syncthing does not descend into any directory matching an ignore pattern in any previous step. The entire file structure below an ignored directory automatically inherits the ‘ignored’ disposition of its parent and those files and directories are never examined by Syncthing.
3. Step 2 is repeated until the entire file structure under the root has received a disposition (either ignored or included).