iOS Quick Tips: Version control and backups with DropBox and Git

Git is an amazing VCS. However, Git by itself is not a backup if you are only using it locally – if your hard drive dies, so does your data. Fortunately, Git’s flexibility lets us do some really cool things, such as push and pull from a ‘remote’ repo on the same machine. When combined with a distributed storage system such as Dropbox, it becomes the perfect tool for the solo developer.

Here’s how you go about using Dropbox with Git. This little tutorial assumes that you already have a local Git repository (perhaps created by Xcode).

Step 1 is to install Dropbox on your Mac. After the install is complete, you’ll notice that you now have a Dropbox folder in your home directory.

Everything you put in this folder will be magically backed up in the Dropbox cloud.

Step 2 is to create a bare Git repository for your project in the Dropbox folder. You can do this from Terminal with the following command, after CD-ing into the Dropbox folder:

git init –bare MyProject.git

This creates the Git repository that your work will be pushed to.

Step 3 is to link your existing Git project with your new Dropbox’d Git repository. After CD-ing into the directory containing your project, issue the following command to add your new Dropbox repository as a ‘remote’ for your project:

git remote add origin ~/Dropbox/MyProject.git

Step 4 is to push your changes to your new ‘remote’ repository:

git push origin master

That’s it! Your local Git repository is now synced with your Dropbox folder. Not only does this give you a safe, distributed backup, but it makes it easy to work on your projects from any machine.

Happy developing!

Leave a Reply

Your email address will not be published. Required fields are marked *