A quick Git/Mercurial with Dropbox primer

28 Sep 2012

If you want dirt-cheap (possibly free) backups for your source code, you can drop a Git or Mercurial repository in Dropbox and work from that. I’ve been doing both for 2 years or so and have never had an issue.

If you’ve never used either Git or Mercurial, I recommend starting with Mercurial and taking 20 minutes to read through Hg Init: a Mercurial Tutorial by Joel Spolsky.

Git

Create your Git project as you usually would:

$ git init /path/to/repo

Create a bare repository in Dropbox:

$ git init --bare /path/to/Dropbox/repo

Add the Dropbox location as a remote within your normal project:

git remote add dropbox /path/to/Dropbox/repo

Any time you want to push to Dropbox, run:

git push dropbox

Mercurial

Create your Mercurial project as you usually would:

$ hg init /path/to/repo

Create a Mercurial repository in Dropbox:

$ hg init /path/to/Dropbox/repo

Edit the .hg/hgrc file within your repository, and add a couple lines that look like:

[paths]
default = /path/to/Dropbox/repo

Whenever you want to push to Dropbox, run:

$ hg push