PSA: Beware locating a local git repository in an iCloud folder

This is more of a "public service announcement" regarding what I've observed than it is a question.


If you're a software developer (or someone who uses git for other purposes) beware cloning any git repository into any local folder that is backed-up into your iCloud account.


For example: my personal Apple ID has iCloud turned on to synchronize my ~/Desktop and ~/Documents folders into iCloud. This is great for backing up regular documents.


However, I recently made the mistake of thoughtlessly creating a ~/Documents/Projects folder (so Projects nested within ~/Documents) into which I've cloned several different projects' git repositories (cd ~/Documents/Projects; git clone git@remote:repo.git).


As long as I haven't switched branches and just make a few local changes and then push them up to a remote, it's not a big deal. However, if a given revision/branch of the repo has lots of files in the working tree, and I start switching between branches/commits where there are substantial differences in the file hierarchy, and if I go about switching branches rapidly... I end up having some fun surprises.


Depending on what the upstream internet speed is (I'm working with 10Mbps upstream; pretty average for those with a cable provider as their ISP) the iCloud sync software will get backlogged trying to upload all the file changes it observes in the working tree as they're rapidly changed. A side effect is that a "git status" will then weirdly indicate the presence of lots of .some-file-name.extension.icloud files which, if careless with git add and git commit, you might accidentally add them your repository.


My recommendation: be careful to clone such repositories into a local folder that is not backed up into iCloud. I've now created ~/projects for all projects where I clone remote repositories. I still keep ~/Document/Projects where I now store my ultimate "source of authority" bare repositories for some local-only or mostly-local-only projects. These I then clone into ~/projects so that this "ultimate upstream" repository's contents can be backed up by iCloud but all working-tree changes and work take place in a location that iCloud ignores.

MacBook Pro 16″, macOS 12.1

Posted on Jan 2, 2022 3:12 PM

Reply

There are no replies.

This thread has been closed by the system or the community team. You may vote for any posts you find helpful, or search the Community for additional answers.

PSA: Beware locating a local git repository in an iCloud folder

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple Account.