MacOS Catalina duplicating files on save
Do you save these files in iCloud Drive? To prevent data loss, iCloud will sometimes resolve sync issues by making a copy with a number on the end that holds the alternate file contents.
There is no way to avoid this, since it's a data consistency measure. You can keep your source code outside of iCloud Drive – I myself have a folder outside of iCloud specifically for Git repositories that are stored elsewhere.