iCloud drive and git repository
I have upgraded some of my Macs to Sierra. Now, I'm wondering whether I want to enable iCloud on the Document folder or not. It seems useful if it works well. I'm syncing some of the PDF files between iPad over iCloud, and my experience was "so-so" compared with Dropbox based sync (I'm using PDF expert on iPad).
I'm particularly interested in how git repository work (or not work) well on the iCloud drive -- I have multiple Macs; I know the iCloud drive is slow in sync.
Do you have any experience or recommendation on this?
I imagine you'll to face the same issues as with Dropbox, when all the little files in the GIT repo are updated with every commit. I understand that the iCloud sync kicks in periodically, so you then depend on how reliable or quick it is (and it seems it can be variable). With Dropbox, I've found this can slow things up while the files are synced and even mess up a repo.
I keep most of my repos in ~/Projects
- after all, you can always pull
and push
(if your remote is on GitHub/BitBucket/etc.) from any machine. If you think it's worth trying, this blog post from 2014 suggests setting up a bare repo in iCloud.
Overall, though, reading around suggests that we "use a dedicated service for git repos designed to store git repos". The aims of GIT and those of iCloud, Dropbox, etc. don't always play nicely with each other, especially if your connection is interrupted or the iCloud service is slow for some reason.
I have had bad experiences with this, although specifically in the case of multiple macs syncing the same cloned repo.
I have a couple of Macs onto which I clone a fair number of git (mostly GitHub) repos. The Macs each have a number of iCloud drive synced directories (in fact I've gone all-in and am syncing Desktop
and Documents
).
I have tried to clone into the iCloud-synced directories. However, I have been having lots of problems with this. It seems very easy to get into a condition where iCloud (not git) gets so confused that one machine effectively stops syncing, even files that have nothing to do with the cloned directories, and even if I carefully re-sync each of the two clones to the exact same state. I don't know if the problem is files under .git/
or just something like race conditions between versions of the actual repo files.
I've tried to use Apple's various iCloud logging tools under brctl but that has generally not helped.
(Most of this has been posted as a question over on the main SO site: has anyone else seen this or anything like it?)
(This is somewhat different from this question which mostly seems to care about a single Mac with iCloud drive, and I don't think users in that situation would see the same issues that I am.)
As others said, there are plenty of issues with storing the git repo in a cloud service. My Mac was constantly syncing to iCloud due to me having an IntelliJ Java project in a folder being synced with iCloud Drive. My git repo was in the same IntelliJ project folder. My fan was spinning nearly constantly because the bird process was at 99% CPU usage constantly.
I recently solved this for myself:
- Make a bare git repo in a folder synced to the cloud (spoiler: and push your current code into it).
- Make a dev folder outside of the cloud folder. This folder should not be synced in the cloud. This is where you write code from this point on.
- Pull from the bare repo to your dev folder.
- Write code in the dev folder and push to the bare repo as a remote whenever you make a commit.
- If needed, pull from the cloud synced bare git on other computers that you work on.
The above prevents the cloud storage application from constantly syncing all of the changes that occur when compiling in the project and committing to git. Only the pushes to the bare repo will get synced to the cloud, which reduces the cloud syncing activity.
I push every time that I commit now. I think the files generated from the compilation and build process were the root issue for me.