17

When creating a Git repository inside of a Dropbox folder using the GitHub application for OSX I get the following message:

Putting git repositories inside of a Dropbox folder is not recommended. Are you sure you want to create a repository here?

Why isn't that recommended?

random
  • 9,774
  • 10
  • 66
  • 83
Oskar Persson
  • 6,605
  • 15
  • 63
  • 124
  • where did you get that warning? – Nikola Oct 10 '13 at 19:59
  • If you add a Dropbox folder using File > Add Local Repository in Github for OSX the message will appear. – Oskar Persson Oct 10 '13 at 20:00
  • possible duplicate of [Dropbox and git, could it cause conflicts?](http://stackoverflow.com/questions/8226256/dropbox-and-git-could-it-cause-conflicts) – Rudi Oct 10 '13 at 20:09
  • 1
    [this question](http://stackoverflow.com/questions/1960799/using-git-and-dropbox-together-effectively) has some good discussion. TL;DR: Dropbox merge conflicts could corrupt your repo by overwriting files inside `.git`. Bitbucket offers free private repo hosting if you don't want to pay for Github –  Oct 10 '13 at 20:17
  • 1
    possible duplicate of [Mercurial (and, I guess Git) with Dropbox: any drawbacks?](http://stackoverflow.com/questions/1964347/mercurial-and-i-guess-git-with-dropbox-any-drawbacks) – random Oct 10 '13 at 20:39
  • Explained well here https://stackoverflow.com/questions/1960799/using-git-and-dropbox-together-effectively, along with a solution (use `git-remote-dropbox`, which is built specifically to solve the problems) – matt wilkie Oct 21 '17 at 19:37
  • Possible duplicate of [Using Git and Dropbox together effectively?](https://stackoverflow.com/questions/1960799/using-git-and-dropbox-together-effectively) – matt wilkie Oct 21 '17 at 19:38

2 Answers2

14

If people are modifying files and using dropbox to do the syncing, you will likely run into problems.

If you use dropbox as a convenient way to give people read only links to your work, then I have found no issues with this and have been doing it for years.

SwimBikeRun
  • 4,192
  • 11
  • 49
  • 85
  • 4
    I just Dropbox to store all my Git repos, some being enormous (paid Dropbox account). No one else but me has access to the Dropbox folder but I do use it on two different computers sometimes switching back and forth at the same desk. I been doing this now for about 6 months and have not had a single issue. I think the warning is just as a precaution. But these are just local dev files. I use Bitbucket & Github for hosting. – Brady Aug 07 '15 at 11:13
  • 1
    me too... I use Dropbox and never got anything corrupted. Google Drive breaks sometimes, but DP does a really good job. – Wagner Patriota Jul 12 '16 at 00:00
  • 5
    I have run into a problem where dropbox and git keep fighting over an index.lock file that gets left over during an operation. Otherwise I haven't found a problem. – kennyB Aug 14 '16 at 01:02
  • 2
    This is correct, and I can't say that it should be avoided at ALL COSTS. This is one of those "it doesn't hurt until it makes you bleed out and die" type of bugs. My advisor used this setup and it ended up causing major issues b/c an IDE had lock files on one laptop open and then he tried to open the project on a different machine and it was impossible... b/c DropBox refused to let him delete the lock files from the other machine... Plus you can get into some very hairy synchronization issues if you are AT ALL unlucky. IF "Murphy's Law" doesn't affect you, go ahead... otherwise good luck – mawalker Nov 08 '16 at 18:10
3

DropBox and other similar cloud disk services such as SpiderOak will mess up your git index files because it might try to synchronize in the middle of these files modifications, and so it will upload a partial state and will then download it back, completely corrupting your git state.

Luckily, this is easily fixable by coming back to the last state using git reset --keep.

Then, to avoid this issue, you can:

  1. Bundle your git index in one file using git bundle create my_repo.git --all.
  2. Set a delay for the file monitoring, eg 5 minutes, instead of instantaneous. This will reduce the chances DropBox synchronizes a partial state in the middle of a change. It also helps greatly when modifying files on the cloud disk on-the-fly (such as with instantaneous saving note-taking apps).
gaborous
  • 15,832
  • 10
  • 83
  • 102
  • 4
    "set a delay for file monitoring" is this a setting you have found in the dropbox preferences? or are you referring to a git command. I want to start this as a process between a work desktop and a work laptop so my working files are a perfect copy no matter what machine i happen to have in front of me. – Bardsworth Jul 20 '17 at 20:07
  • what exactly does it mean to "bundle the git index in one file"? It is more than one file normally? And why does that help? – Homero Esmeraldo Jun 14 '19 at 16:41
  • 1
    @HomeroEsmeraldo Yes it is usually stored in multiple files true to its original conceptor's idea of "everything is a file" (Linus Torvalds). This can help because it would avoid starting the synchronization for one file and then missing out on other files, and then mangling up by restoring these other files to an older version, which would conflict with the other files in the index that were correctly synchronized. At least that's the theory, but in practice I still had issues. – gaborous Aug 11 '19 at 01:17