Philip Guo
    (Phil Guo, Philip J. Guo, Philip Jia Guo, pgbovine)
Main Menu

Lightweight File Versioning and Synchronization with Git and Unison

by Philip Guo (philip@pgbovine.net)

Today I found a lightweight and elegant solution to the problem of maintaining my personal website on the MIT webserver: http://web.mit.edu/pgbovine/www/. I was seeking a solution that met the following two requirements: I wanted to be able to edit files locally on my computer, and I also wanted version histories of my files both for archival purposes and to protect against accidental mistakes.

My solution involves two programs:

I really like this solution because it's fast, conserves disk space, and is portable:

Contrast with my former CVS setup

For the past 2 years, I've had my entire website inside a CVS repository housed on the MIT webserver. I did a checkout on my laptop (or on any other machine where I wanted to work), and whenever I wanted to push my updates, I would do a cvs commit to the server. But that step alone wasn't adequate for those changes to be seen publicly. I also had another checkout of the repository on the MIT webserver located in my www/ sub-directory. After committing my changes from my laptop to the repository on the server, I had to then log in and run a cvs update to pull the latest changes from the repository to the www/ directory so that they could be publicly visible.

I always had to do 2 remote CVS operations whenever I wanted to update my website, and those were always soooo slow since I naively had all my files in my repository (including the large image files that don't ever change). Also, there were essentially two copies of my website on the MIT webserver (the publicly visible copy and the 'copy' that's actually the contents of the CVS repository), which took up extra disk space that counted against my quota.

I finally got fed up with how slow it was for me to update my own website using CVS and decided to switch over to the Git and Unison solution. Now I can edit and commit as many changes as I want locally, and then just run Unison once over ssh to sync my changes to the www/ sub-directory on the MIT webserver. Running Unison to sync the files is far faster than running a cvs commit over my entire website directory tree.


Created: 2007-09-14
Last modified: 2007-09-15