Thursday, July 5, 2012

Git remote Dropbox

I wanted to make a quick note mainly for my own memory, but if it helps anyone else out, well all the better. I do really like Github, but there are times that my work/code just isn't ready for public consumption (not that too many people seem to dig into my Github work). Which leaves me with the question, where should I backup my repository?

My quick and dirty solution appears to be Dropbox. With the way git works, it's quite simple to use a dropbox folder as a kind of "central repository" that's automatically backed up while remaining private.

So here's the simple method I used; first create a bare repo in Dropbox:

cd dropbox-directory
git init --bare project.git

This is a very simplistic analogy to what happens when your create a new repository on Github.

Now we need to push the local repository to the new "remote" Dropbox repo:

git remote add dropbox dropbox-directory/project.git
git push -u dropbox master

The '-u' parameter will automatically set up tracking, so if you use 'git pull', any changes stored in the dropbox repo will be pulled into the local repo. Also, master is simply the default branch name, so you can substitute it with your desired branch name if necessary.

Lastly, to make a clone of the repo, all you need is to have dropbox installed and then use the command:

git clone dropbox-directory/project.git
cd project

No comments:

Post a Comment