"Google Drive can corrupt repositories" in Github Desktop
Asked Answered
S

3

14

I primarily work out of a Google Drive folder and it is mentioned in Github Desktop when creating a new repository that "Google Drive can corrupt repositories".

enter image description here

What are the issues specifically and what can be done to avoid repositories being corrupted?

Shown answered 13/8, 2015 at 9:44 Comment(0)
M
31

We've put that warning in place because we've seen quite a few users get their repositories corrupted by various cloud-backed storage solutions such as Google Drive and Dropbox.

The problem boils down to a race condition where Git creates and modifies files rapidly and the storage solution trying to keep up. In some scenarios this can lead to file IO not behaving as Git expects. A storage solution might also erroneously restore a file that was meant to be removed. While these sort of issues are most likely to occur when you're sharing the repository with other people we've seen issues with people who only use the storage for backup purposes.

The best way to backup Git repositories is to commit early and often and push your changes to GitHub frequently, even if you push them to work-in-progress branches rather than master or other long-running branches.

If you're not using GitHub or any other remote and your repository is local I'd recommend creating a bare repository inside your Google Drive and then clone your repository to a location outside of Google Drive and work from there. Whenever you've made changes you can push those to the bare repository. That way you'll have two copies of all your data in case the Google Drive version gets corrupted.

Morningglory answered 2/9, 2015 at 22:19 Comment(2)
This is the way I have been doing it. Thanks for validating.Brigham
A bit late here, but for context: I have had git repos in my GDrive in the past, not in order to back up the repo, but just because the repo is a subdirectory of a project that I did want in a cloud drive (for project docs, specs, assets etc). In those cases I would have preferred not to have the git repo syncing at all, but it was a fait accompli as Google Drive doesn't have an exclude mechanism. Some competitors (eg. Mega) do, but they come with their own problems. These days I symlink to the git dir (which GDrive doesn't sync). But maintaining parallel dir hierarchies is not ideal.Brevity
P
1

Google Drive already messed up my life two times (yes I needed to see the second to believe).

My solution to avoid forgetting push to a safe place I've created some automated tasks. You can create a scheduled task to commit and push your changes every each X hours/days...etc. to one work-in-progress branche for example. Using Unix based systems (Mac / Linux) you can use crontab.

First create one bash script, i.e: /home/myScripts/autoGit.sh

# add and commit changes
cd /home/myProject && /home/myGit commit -a -m "automated commit/push `date`"

# push git server
cd /home/myProject && /home/myGit push origin wip

Then you create your crontab job as needed:

crontab -e

then add the commands to the file

mailto: [email protected]
59 * * * 1,2,3,4,5 /home/myScripts/autoGit.sh

This will commit and push your repo every each 59 minutes on mon,tue,wed,thu,fri.

Hope it helps

Puncture answered 10/8, 2016 at 18:50 Comment(0)
N
0

(Google Drive File Stream user) I am currently having this problem, and the solution I found was having my git repositories in a non-synced hard disk, and then create a mirror folder for each one inside the GoogleFileStream Drive, which gets copied every time I execute a .bat script, with the robocopy command (Windows).

robocopy "\\Git\to\repo1\nonsynced" "\\Mirror\target\git\repo1\to\sync" /E /MIR

robocopy "\\Git\to\repo2\nonsynced" "\\Mirror\target\git\repo2\to\sync" /E /MIR

I perform the commits and pushes as usual, and run the script to sync with drive. This can be automated with a FolderMonitor script, or task scheduler command.

Novelistic answered 18/12, 2020 at 0:8 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.