Edmund's technical ramblings

github linkedin email
Yes, Virginia, You Can Use Git in Dropbox
Jun 16, 2021

Conventional wisdom holds that you should not keep your git checkouts in Dropbox, because, basically, both Dropbox and git believe they have the right to do sketchy things to the files they control, and that adds up to too much sketch, and your git repo will get corrupted.

I can say from painful experience: conventional wisdom is correct.

This is a bummer if, say, you are a heavy org-mode user who both wants keep your org files version controlled, as $DEITY intended, and also sync those org files to Dropbox for use with mobile tools like orgzly, org-web, or organice.

However, since git 1.7, there is now a way to make this work! You can tell git to keep the .git directory outside the checkout directory, like so:

cd ~/Dropbox
git clone \
    --separate-git-dir=/path/not/in/dropbox \
    server:repo.git checkout-dir

Now ~/Dropbox/checkout-dir/.git will be a file, not a directory, with contents like:

gitdir: /path/not/in/dropbox

Dropbox will sync the .git file normally, and—as long as you have the same directory structure on your machines (which I do) or are willing to do some symlink magic to make them appear the same, you get checkouts synced by Dropbox for use in mobile tools, and git to track revisions and sync to other git-aware boxes.


Back to posts