Issue with Git Restore files getting deleted even after they have been restored in Git using Git restore

358 Views Asked by At

I have a sub-directory where I have files in the local Git Repository. They automatically get deleted and I keep restoring the files using git -restore. For example the file diamonds.csv (which gets deleted) a file .diamonds.csv.icloud created in my directory. I have tracked all such files and commited to my remote repository. But the problem persists. I am unable to do my work as I have to constantly restore my files.

1

There are 1 best solutions below

0
On

Since you mention a .icloud file, my guess is you placed your repo within a folder which is auto synced with iCloud.

I strongly advise that you completely disable cloud syncing on your working repo.


You are probably witnessing the effects of iCloud affecting your worktrees, which is annoying, but recoverable.

The problem is : git stores all of its information in files on disk (in a hidden .git/ folder located at the root of your repo). If iCloud starts overwriting files there (for example : helpfully overwrite the index file with the version saved in the cloud, or any of the refs/, ...) then this can literally break your repo.


The minimum step is to turn off the "cloud to my computer" part of the syncing while you work, and make extra sure that the version of your repo stored in the cloud contains your changes.
You would also have to be careful with other devices that auto sync with this iCloud account, as modifying the repo on any of these devices may upload that version to the cloud, and then overwrite the version on your workstation.