10

First off, I'd like to emphasize that this question is NOT about hosting my central repo on Dropbox, and that I'm fairly new to using git. None of the other questions involving Dropbox and git that I could find really answer my question; they're all either about hosting your repository with Dropbox or whether or not it's a "good idea" to use the two in conjunction, neither of which is what I'm asking about here.

My question is as follows: I have two computers, each dual-booting Windows and Ubuntu (a laptop and a desktop). I've got my local git repository (cloned from a github repo) located in a Dropbox folder so that it is synced across machines and operating systems. When I make a commit on one machine/operating system, it doesn't seem to be syncing the commit status properly to the other machines.

e.g.:

On my Windows desktop, I make a change to foo.cpp. I then 'git commit -a' and 'git push', pushing my changes to the github hosted repository. The changes to the files are also synced across my Dropbox folder, and when I log into my Windows laptop at school, everything is downloaded without issue. However, when I type 'git status', it says:

# On branch master
# Changes not staged for commit:
#   (use "git add <file>..." to update what will be committed)
#   (use "git checkout -- <file>..." to discard changes in working directory)
#
#       modified:   foo.cpp
#
no changes added to commit (use "git add" and/or "git commit -a")

But I've already committed these changes on my other machine in, ostensibly, the same working directory. An attempt to 'git pull' from the github servers gives me the message that everything is 'Already up to date.'

I would have hoped that the repository status would be seamlessly synchronized by Dropbox. Is anybody familiar with a way around this situation? Thanks!

wickstopher
  • 981
  • 6
  • 18

1 Answers1

11

TL;DR

Don't use Dropbox for concurrent operations with Git.

Eventual Consistency Will Cause You Grief

Dropbox gives you eventual consistency. Using it as a backing store for critical Git operations is a Bad Idea™. It's even worse if you're using it as a working tree rather than as a bare repository. You can certainly do it, but you need to grok the limitations of this approach.

Dropbox and Spideroak Hive are fine if you want to use synced directories as a working tree for one user at a time. Just make sure that your files and folders are fully-synced before accessing them from another system. As long as you stick to a single-user, single-system workflow you shouldn't run into trouble, but your mileage may vary.

Timestamps

You may also run into problems if you're using multiple machines that don't agree on the time. If you aren't running NTP, one machine's clock could be ahead or behind of the other. This can lead to situations where the syncing service thinks a new file is in fact an older file (or vice-versa). In short, anything relying on timestamps may be error prone.

The accuracy of the timestamps are especially important if you are using GNU make or other tools that rely on them. If you're going to use Dropbox to synchronize a working tree, make sure your timekeeping is accurate across all systems that will touch that tree.

Todd A. Jacobs
  • 81,402
  • 15
  • 141
  • 199
  • Yeah, I should've made it clear that I'm the only one accessing these repositories. I wouldn't think of using Dropbox for a team git setup. This doesn't really answer my question, but I appreciate the information/perspective. Perhaps it's overly paranoid to use distributed version control inside of a Dropbox setup...? – wickstopher Aug 31 '13 at 17:00
  • I'm just trying to figure out a workflow...I'm moving from just Dropbox to trying to incorporate git into my workflow. Perhaps move the working directory into Dropbox as I'm working on it, making a commit when I'm done, and then moving the directory out of Dropbox when I'm done. I was hoping that Dropbox would play nice, but I can see now that it might not be the best solution. – wickstopher Aug 31 '13 at 17:06
  • @cecilg23 I think it does answer your question. See https://git.wiki.kernel.org/index.php/Git_FAQ#Why_isn.27t_Git_preserving_modification_time_on_files.3F or dig into how Git determines what files are "new" if you want more information on the underlying implementation. IMHO, you are running into either sync or timestamping issues. Whatever you decide to do, I wish you good luck! – Todd A. Jacobs Aug 31 '13 at 17:09
  • 1
    @cecilg23 +1 for CodeGnome answer. Dropbox + git means bundle only: http://stackoverflow.com/a/3633346/6309 and http://stackoverflow.com/a/9851166/6309, and http://stackoverflow.com/a/9030201/6309 – VonC Aug 31 '13 at 20:39
  • @CodeGnome thanks for the insight. I think I'm going to change my workflow to something more like what I had outlined above. I think I was leaning towards that to begin with, but I needed one last-ditch effort at trying to incorporate Dropbox in that way. – wickstopher Sep 01 '13 at 03:05
  • FWIW I have personally been using full working copy git repos in dropbox to sync work and home computers for several years without incident. When I leave work dropbox has completed the sync by the time I get home and then vice versa in the morning. I've never done anything fancy like bundles. Of course if anything goes horribly wrong I always have my actual origin server to git everything back to normal. – Justin Ohms Feb 26 '15 at 20:04