git push dropbox master

As mentioned in a previous post, I’m a big fan of creating lots of little Git repositories around my home directory for nearly every minor project or subproject that I work on. It’s kinda like the opposite of how Google manage their codebase.

For projects that (a) you don’t want public, (b) need a quick push-to-the-cloud strategy for, (c) aren’t massive, and (d) won’t be used by anyone else, you can just use your Dropbox account as a remote repository to push to.

This way, you get a little peace of mind that your project exists elsewhere (on someone else’s computer), and the ability to pull from another of your Dropbox-linked machines.

How to add Dropbox as a Remote Repository

So, you have a cool project that you want to push to Dropbox. Let’s see how to set that up.

First, create a new directory in your Dropbox to house all of your remote repositories. I creatively call mine, “Repos”.

For your first remote repository, create a subdirectory to house it, and initialise a “bare” Git repository inside it:

This is what you'll see in your Dropbox after initialising a bare repo.
This is what you’ll see in your Dropbox after initialising a bare repo.

This “bare” repository has no commits, or even any branches. It’ll happily accept anything pushed into it, though – which is what we’re going to do now.

Change directory into the local Git repository you want to push, and add your Dropbox “bare” repo as a remote:

Note that I’ve specified the full absolute file URL here as I personally would not rely on the tilde expansion working on every platform. Assuming we want to push our default master branch, we can now push our latest commit:

If you have Dropbox sync enabled, you should now notice it syncing with Dropbox’s servers. If you want to work on the project from another machine, you’ll be able to clone it:

From there, you can commit and push, and pull from your original machine.

Caution: This is not a Backup!

Note that I purposely avoided using the word “backup” for this method. I do not consider this strategy as a backup because ultimately you could screw up your Git history in some way and then push the mess to Dropbox.

It should never be possible to modify a backup. A backup should be written, verified, and left alone except for routine verification.

Aside: Yo Dawg!

Dropbox automatically keeps a limited number of past versions of your files as an additional safety mechanism. So you’re getting a history of your project histories.

https://cdn.meme.am/instances/500x/35038010.jpg

Leave a Reply