1

Every so often I'll check my git status and I'll find a whole bunch of newly created (basically duplicate) files that are just copies of existing files with the character number '2' appended at the end e.g.:

        .github/CODEOWNERS 2
        .storybook/webpack.config 2.js
        .vscode/launch 2.json
        __mocks__/data/Account 2.json
        __mocks__/data/Basket 2.json

I've tried deleting the whole repo and re-cloning it. I've also restarted my machine and checked that there are no active merges or rebases.

Morris
  • 135
  • 4
  • 3
    What environment are you in? Are you using a CLI any other tool? Are you sure this is not the doing of some other program and Git is simply showing you the status? – Qumber Jun 15 '20 at 09:32
  • Using VSCode and CLI for git itself, but you're right, maybe it's something else doing it although I have no idea what could be doing it. I have Git Lens extension, maybe i'll try disabling that :shrug: Thanks for response – Morris Jun 15 '20 at 09:50
  • 1
    It's iCloud!!! It duplicates the files for some reason and messes up your working directory. – Morris Jun 15 '20 at 10:35
  • Please turn that last comment of yours into an answer. Tone down the language while you are at it. You can even accept your own answer. The question is not strictly programming related, but probably matches the category "concerning tools a programmer has to use regularily". So I'd let it pass as on-topic. – Yunnosch Jun 15 '20 at 10:42
  • Does this answer your question? [ICloud Drive Desktop Sync vs. Git - deleted files reappear and duplicates with number suffixes](https://stackoverflow.com/questions/59308049/icloud-drive-desktop-sync-vs-git-deleted-files-reappear-and-duplicates-with-n) – matt Jun 15 '20 at 12:04

1 Answers1

1

Turns out that this is caused by iCloud. If you have your git repo inside of your Documents folder (or you have an alternative folder selected to be backed up that happens to hold your repo) then it will create these duplicate files when it attempts to back up. Git will then mark them all as added files and it will wreak havoc with your git version control.

Solutions:

Do not use git inside of your Documents directory on a Mac. (i.e place your work somewhere else on your hard drive) OR Turn off iCloud Drive backup

Morris
  • 135
  • 4
  • Identical to https://stackoverflow.com/questions/59308049/icloud-drive-desktop-sync-vs-git-deleted-files-reappear-and-duplicates-with-n etc. – matt Jun 15 '20 at 12:05