Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Git keeps duplicating files and appending ' 2' at end of filename [duplicate]

Tags:

git

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.

like image 795
Morris Avatar asked Nov 26 '25 13:11

Morris


1 Answers

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

like image 164
Morris Avatar answered Nov 29 '25 10:11

Morris



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!