Placing a github repo into a cloud synced folder (GDrive, Dropbox, iCloud, OneDrive etc)

What are some of the drawbacks of having a GH repo living in a folder that syncs to the cloud and lives on 2 computers?

I feel like someone in the past (possibly @jennybryan) warned against such setup. What are the potential problems with it?

Cloud synced folders will try to sync the .git folder. This folder has all the information that Git use to version control your project. Have GDrive, Dropbox, iClode, OneDrive, ... manipulating those files can be a little problematic. For example, on PC1 and PC2 you might have

$ cat .git/HEAD
ref: refs/heads/master

If on PC1 you change branches, you will end up with

$ git checkout foo
Switched to branch 'foo'
$ cat .git/HEAD   
ref: refs/heads/foo

GDrive, Dropbox, iClode, OneDrive, ... will notice that .git/HEAD and will add it to the synchronisation queue. At some time, PC2 will receive instructions to update .git/HEAD. Have your branch changed on PC2 might be something that you didn't want to happen. Is also possible that Git on PC2 will find some temporary problem because the synchronisation didn't finished, for example HEAD is one commit that doesn't exist on PC2.

2 Likes

I don't have a well-written argument against this practice and I know that many people do successfully use Git with repos/folders that also live in a cloud-synced location. So I suppose my answer is: if it's working for you, be thankful and carry on. But don't be surprised when things go wrong.

A hearty "yes" to everything that @rgaiacs just said above. I personally find it very frustrating that there is no concept of ".dropboxignore", for example.

And I have definitely helped individuals, in my Git teaching life, who had very concrete problems with Git repositories that a service like DropBox or OneDrive was also trying to manage.

3 Likes

Thank you!
If anything, git inside a cloud-synced directory is an unnecessary complications of affairs, but I have a specific use-case where it may needed to be done.

I'll carefully test it out. Thank you!

1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.