Each time your Mac connects to a Windows computer, it leaves something behind – a .DS_Store file. This very short guide will show you how to stop that from happening.
DS_Store files are created in every folder on your Mac. They contain information about that folder, like the position of icons or the way you want files displayed specific to that folder. Since its purpose is to help macOS itself (not you as the user) they’re “hidden” – by starting the file name with a dot (.) If you’d like more detailed information on .DS_Store files, see this Wikipedia article.
The “problem” with those files is that your Mac will create them when you connect to Windows computers as well, and on Windows, those files aren’t hidden. Fortunately, you can stop your Mac from creating them when you’re connected to a Windows computer.
defaults write com.apple.desktopservices DSDontWriteNetworkStores true