How to stop VS Code to duplicate files? (FileName 2.css)

Viewed 3160

I'm using VSCode in Mac and usually, they auto duplicate some file randomly. I suspect that could be related to some git config or command. As you can see, this time the VisualStudio Code generated only 263 files with 2 at the end of the name, but sometimes this happens to 3,000 or 5,000 files.

Why does this happen?

How can I stop it?

Version: 1.46.1
Commit: cd9ea6488829f560dc949a8b2fb789f3cdc05f5d
Date: 2020-06-17T21:17:14.222Z (2 wks ago)
Electron: 7.3.1
Chrome: 78.0.3904.130
Node.js: 12.8.1
V8: 7.8.279.23-electron.0
OS: Darwin x64 19.5.0

enter image description here enter image description here

This is my current activated extensions.

enter image description here

3 Answers

After a lot of investigation due to files that randomly get:

  • duplicated and suffixed by numbers
  • deleted

I discovered that it was caused by iCloud Drive. It was configured by default to sync my user directory. Disabling iCloud Drive or configuring it appropriately (by excluding any project managed by git) should fix this issue.


In summary, add .nosync in the name of your root file to solve the problem.

Example: Your app folder name is awesome-app, change it for awesome-app.nosync and iCloud will not sync it.

This is definitely not caused by GIT itself. (GIT doesn't..create new files, unless someone tells him to.)

Two thoughts come to mind:

  1. This kind of behavior is not normal in VScode. Perhaps it happens when using certain extensions? For example, the Local History extension occasionally generates extra files.

  2. Looking at it this way, it almost looks like someone copy/pasted a folder into itself, and rather than overwrite files, it created new duplicates of every file. Is it possible that's what's happening?

  3. An easy way to tell if GIT itself is at fault is simply use Notepad++ for a day or two, and see if the problem continues. If the problem goes away, then you know it's related directly to VScode.

You can also exclude files from iCloud by adding .nosync to the file name

Related