maphew

Dropbox and code repositories

Installed git-remote-dropbox

Added auth to dropbox api for "code-repo"

  • It creates a folder under "/apps/code-repo", which confused me for a bit since I already had an "/apps" folder, that has nothing to do with the API

  • Git init doesn't understand the "dropbox://" prototocol, and creates a dir called "dropbox:"

  • So you have to init locally, then add the remote, then commit and push

  • Used "selective sync" to not download "/apps/code-repo"

There are a bunch of guides on the Internet that describe various ways to use Dropbox and Git together. Most of them recommend keeping a bare Git repository in a folder synced by Dropbox and using a folder-based Git remote. 

This seems to work okay for the most part. Except when it doesn’t 

-- http://www.anishathalye.com/2015/08/19/git-remote-dropbox/ 

From http://h4ck3r.net/2010/05/11/mercurial-hg-with-dropbox/ 

First, clone your repo into your Dropbox:

~$ cd ~/Dropbox 
~/Dropbox$ hg clone ~/myproj ~/Dropbox/myproj-hg --noupdate

The syntax is hg clone <from> <to>. The --noupdate flag tell Mercurial to just store the repository data, not to check out a working copy. You’re never going to work directly in the Dropbox directory , but instead use it as a “remote” where you push and pull to and from it. The only thing that will ever be in that directory is the .hg directory, and there’s no user-serviceable parts in that particular one. That’s why I renamed myproj to myproj-hg in the clone step, just so I remember that it’s a Mercurial directory, and it’s supposed to be “empty” (because the .hg will be hidden on Linux).

Second step, back in your original directory, edit your paths to point at the Dropbox backup of your repository:

$ vim ~/myproj/.hg/hgrc

(or your editor of course). Paste something like this (the file will be new/empty if you haven’t added anything else yourself:

[paths] 
default = /home/sgraham/Dropbox/myproj-hg/

Replacing “sgraham” and “myproj” naturally.

Now,

$ hg push 
$ hg pull

will work as expected in ~/myproj, and every time you push, you’ll have a secure, private, offsite backup of your code.

Step Three: Well, that’s it. There’s no more steps.