Friday, January 27, 2012

Combined Dropbox and Git/SVN dev environment



The Problem:
You are using several computers working on the same source controlled project. You need to commit in order to continue working on the code changes on another machine. This will pollute your commit history and force you to commit "dirty" code in order to access it on another computer.

The solution:
I solve this by only having one of my machines properly set up to connect to the source control(GIT or SVN in my case). I keep all the projects I am working on in separate folders in Dropbox. I have my laptop as the main machine using Eclipse as the editor with the SVN and GIT plugins activated.

The Dropbox folder structure looks like this:
dropbox/project1
dropbox/project1/folder1
dropbox/project1/folder2
dropbox/project2

Files can be changed on all machines that shares the Dropbox folders. When a change is made the machine pushes the changes to the other machines in near real-time.

This makes it possible for me to set up "lighter" environments on less powerful machines and still be able to make code changes without firing Eclipse up on my laptop. For instance I am using gvim to edit files on our Atom based net-book. It works a treat but that machine would not be able to run Eclipse properly because of screen estate and power limitations. I don't need to install the GIT or SVN clients either.

When I am ready to commit I do that from the main machine in my case my laptop. This way no commits and complicated branching are needed just to get the data accessible on another machine.

Negatives:
  • It doesn't work very well for local branching in Git. Changing to another branch immediately starts synching the new code to all the Dropbox clients. It works if you do it on the main machine but can be a bit confusing.
  • You can only commit from the main machine.
  • Since the .project in Eclipse and other dot files are being synchronised by Dropbox you always have to use relative paths in these files if you put the Dropbox folders in different places on the different machines.


Positives:
  • You get the bonus of the Dropbox real-time versioned backup.
  • No need to commit code to continue working on it on another computer.
  • GIT or SVN client only has to be available on the main machine.

Tips and Trix:
If you absolutely have to be able to commit from all machines where you are editing the code it is good if the main machine is always on and accessible over the internet. A cloud server makes the perfect candidate for being the main machine.


Just set up an ubuntu server on for instance www.rackspacecloud.com.
Install http://www.dropbox.com/install?os=lnx

Install GIT or SVN so that we can commit the changes via an SSH login when ready.
Start Dropbox on the cloud server to pull down all the most recent changes.

Now commit from the command line.

One more benefit with this is that you can edit files via ssh and an editor like vim from anywhere in the world and you get instant backup and synch in to the main machine.








No comments:

Post a Comment