In Total Commander → Commands → Synchronize Dirs, use the file filter field between the two directory paths. Put exclusions after a vertical bar |.
For example:
*.* | .git\ node_modules\ cache\
This synchronizes everything except directories named .git, node_modules, or cache. The trailing \ is important—it tells Total Commander that the pattern is a directory, not a file. These names are excluded wherever they occur in the directory tree. (Ghisler)
You can also exclude directories by their position:
*.* | \temp\
excludes temp only directly under the synchronization root, while:
*.* | project\data\temp\
excludes only that particular relative path. (Ghisler)
So, for a typical development tree I might use:
*.* | .git\ node_modules\ vendor\ .idea\ .vscode\
You can save this as part of a Synchronize Dirs profile, so you don’t need to enter it each time. (Ghisler)
In Synchronize directories, configure everything first: left/right directories, your filter such as
*.* | .git\ node_modules\ cache\
and options such as Subdirs, Asymmetric, etc.
Then click the small yellow folder icon with a star in the upper-left corner of the Synchronize directories window. Alternatively, press F2. This opens the saved-settings dialog. Choose Add current directories/settings, give the configuration a name, for example MyProject, and save it. Total Commander can save the paths, synchronization options, display options, and—importantly—the wildcard/exclusion filter. (Ghisler)
To use it later, open Synchronize directories, click that same folder icon (or press F2), and select MyProject.
You can also make a Total Commander toolbar button that opens the saved profile directly. Modern TC versions support:
SYNCOPEN MyProject
as the button command. (Ghisler)
That is particularly convenient if you have profiles such as Backup, WebServer, and SourceCode, each with different directory exclusions.