21

I realize that there are similar questions, but my question is slightly different: I'm wondering whether sharing a bare repository via a synchronized Dropbox folder on multiple computers would work for sharing code via Git?

In other words: is sharing a Git repo via Dropbox the same as sharing it from one centralized location, for example, via SSH or HTTP?

Does the repo get updated on each person's local drive? Is this the same as sharing a Git repo via a shared network drive?

Note: This is not an empirical question: it seems to work fine. I'm asking whether the way a Git repo is structured is compatible with this way of sharing.

EDIT To clarify/repeat, I'm talking about keeping the Git repository on Dropbox as a bare repository. I'm not talking about keeping the actual files that are under source control in Dropbox.

4
  • 1
    DropBox doesn't have any sort of version control: whichever computer has the newest shared file, that file is pushed onto all the other computers. That's the only issue that would bother me in such setup. Feb 4, 2010 at 12:49
  • @Piskvor, fixed the question, hope it's clearer. Feb 4, 2010 at 12:52
  • 1
    Lots of duplicates: stackoverflow.com/questions/tagged/git+dropbox
    – Josh Lee
    Feb 18, 2011 at 17:25
  • @jleedev, yes, but few of them predate this one :) Feb 20, 2011 at 0:47

8 Answers 8

20

I see no reason why it would lose data -- Git's repository structure is robust, and in the repository store itself, files with the same name will always have the same content (this doesn't apply to branch names).

It's not going to be efficient, though. Git's transfer protocol means that it will usually only transfer a change once. With Dropbox, if two people pack slightly different repositories, the packs generated may contain significant common data while not being identical, so DropBox would sync both packs, which is inefficient.

You may also find that, although the data is all there, you wind up with un-tracked changes due to two copies both having the same branch updated at the same time. This can be worked around by ensuring that you push to different branches from each copy, but it'd be a pain.

7
  • Andrew thanks for that, +1. The untracked changes due to two people working on the same branch at the same time is the kind of thing I wanted to know about. Feb 4, 2010 at 12:54
  • you mean that if two devs chose the same branch name there would be conflicts? Feb 4, 2010 at 13:01
  • Yes, the commit referencing the current tip of the branch is stored in a file under refs. If two devs push to the same branch without a sync, both sets of commits will be stored, but only one will be referenced. Feb 4, 2010 at 13:18
  • Okay, that makes sense, thanks. I in fact had to find some commits that were not in any branch this week, so I know that it's possible, but not ideal.. Feb 4, 2010 at 13:34
  • @andrew-aylett - Wonder what you think of this scenario. We have our Git repo stored on our Windows network (the powers that be, don't want our code public, yet we are small enough that we are hoping to not pay for a hosting service when not really deemed necessary). Currently, if we want to push/pull to the bare repo, we VPN and do appropriate action. Was thinking we could put repo in dropbox, so that we have the repos duplicated on our box for fast (non-vpn required) pulls. But we always have to VPN to do a push and always only push to the one location. This would avoid conflicts right?
    – Terry
    May 12, 2011 at 15:35
15

I'm pretty sure that this is unsafe. There's a bunch of moving parts in a Git repository, and Dropbox could easily wreck one of them. For example, you might end up with incorrect branch tips (master, etc.) in the refs directory, or your object store might stop working if the objects/info/packs file has the wrong contents. Git repos are fairly simple and robust, but they are not just dumb unbreakable storage.

Accessing remote repositories through SSH, git, or HTTP, or even locally on a network file system, is safe because the repository is only accessed through a git process, which makes sure that everything is moved into place in the right order. But Dropbox doesn't make any kind of guarantees about ordering, so you might lose data.

Just use a Git server (or any SSH server) instead -- if you don't have one, GitHub, Bitbucket or GitLab come to mind. It'll save you a lot of trouble, and it's no harder to use than a local repository shared through Dropbox (you just have SSH URLs instead of local paths).

2
  • 2
    Github has constraints (must be open source or you must pay), but Unfuddled (for instance) does not. But yeah, point taken about the dropbox. Feb 20, 2011 at 0:48
  • @Yar Thanks for the tip with Unfuddle; I've updated my answer. :)
    – Jo Liss
    Feb 20, 2011 at 2:29
12

What happens if two users are disconnected, do some work, push to their local copy of the bare repository and then go on line? In this case, when Dropbox tries to synchronize you'll get problems -- pack files and branch tips will be different and Dropbox can't fix that. That's the only problem I could see. I think the same thing could happen even if both users are connected, if they happen to be pushing into their local bare repositories at the same time.

2
  • Thanks Pat, that seems to be the concern. So basically, while my DropBox strategy is great for backup, for sharing it's essentially useless due to these offline-online problems. Feb 4, 2010 at 15:14
  • The good news is that there's lots of free Git hosts out there and it's nearly trivial to set up a central repository if there's a server you all have SSH access to.
    – kubi
    Feb 4, 2010 at 20:06
9

I've had problems using Dropbox with Git and with Mercurial. Repository files often get corrupted, presumably due to Dropbox's synching not being perfect, particularly when changes are being made from multiple places. Also, Dropbox works in the background, so it is really easy to accidentally try to use the repository (or reboot your machine) while it is in the middle of a sync operation.

I love Dropbox, but it is not a good replacement for a shared drive or a "real" remote Git repository.

1
  • 1
    Yes. Especially when unfuddle (and a lot of others) give you (small) repos for free. Thanks for your answer. Jul 16, 2010 at 16:54
5

I used to do this with MobileMe, but the computers kept getting out of sync. Each computer would have a repo that was different than the one in the cloud and since there's no concept of "merge" in MobileMe (and I assume, DropBox, too, right?) I'd end up just having to either pick a version to keep and lose some edits, or copy the edits out and re-apply them. Life has gotten a whole lot easier since I switched to a central Git repo.

If it's working for you so far, good. I imagine you're going to have a lot of pain if two devs push to their local bare repos at the same time, though. How's DropBox going to know which is right?

5
  • That's the question. I thought that, due to hashes, there is never any conflict... ? Feb 4, 2010 at 12:53
  • I don't see how the computer could get out of sync. Obviously you would have to push and pull from the MobileMe repo Feb 4, 2010 at 14:27
  • Check out @Andrew's response, that's the kind of thing I was referring too. All your objects should sync with no conflicts, because of the hashes, but any files not named with hashes could cause conflicts. At least with MobileMe, conflict resolution is minimal.
    – kubi
    Feb 4, 2010 at 14:46
  • Same with DB I would guess. How would it resolve binary file conflict, anyway? Feb 4, 2010 at 15:14
  • I did it with timestamps, which usually meant one set of changes either had to be discarded or manually re-applied. It didn't happen that often, but it was a pain.
    – kubi
    Feb 4, 2010 at 15:25
3

If I told you that there are cases in which Dropbox has screwed up my Git would I answer your question by contradiction? At least in my experience, this has happened more than 5 times and there are a lot of people having the same experience out there.

But nowadays I don't believe that Dropbox is really that essential with Git, really. Actually you can set remote branches (Github, Gitorious, Bitbucket) which can replace Dropbox sharing and revision history features (isn't all that about Dropbox?) and offer you even more.

1
  • Actually using git with files that are in Dropbox will result in sync problems, unless you work on just one computer. Sep 29, 2012 at 23:40
2

One problem with DropBox has to do with how they handle historical backups. While you can roll back an individual file (within the last 30 days, or forever if you have PackRat), you cannot roll back entire directories. This means that if your repo gets screwed up for any reason, the amazing service of having a historical backup is essentially useless, since you would have to click on thousands of files to bring them back to an earlier version.

And then there are the problems with race conditions, if you will, mentioned by most of the other answers.

0

I just host my repository on github.com as a private repository. Yes, you have to pay for a Micro plan ($7/plan) but you have the security knowing you have a backup of your code externally.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.