Archive for March, 2008

Git on MacOSX

Sunday, March 23rd, 2008

I've been playing with Git lately and wanted to share some instructions and gotchas. I've installed Git on 10.5 and 10.3 (which needs a few extras installed) but haven't tried them on 10.4 yet, let me know how it goes. From my experience, version control is way underutilized (at least in non-computer engineering) and would reduce the amount of duplicated effort, improve the ability to collaborate, and keep detailed history of important text files (like say your thesis if you're using LaTeX, which you should be). Other version control systems I've used are subversion and perforce, but I like git because it's super fast, it's pretty easy to manage remote repositories over ssh, and it's hot right now.

Initial Setup

As usual, you need to have the Developer tools installed.

Edit  ~/.bash_login (for just you) or /etc/profile (for all users on your computer)to add /usr/local/bin + sbin to your $PATH variable, e.g. add the following line:

export PATH="/usr/local/bin:/usr/local/sbin:$PATH"

Build and Install Git

curl -O
tar -xzvf git-
cd git-
./configure --prefix=/usr/local
make all
sudo make install
cd ..

If you get a compile error about po/de.msg make[1]: *** [po/de.msg] Error 127 then you should just be able to run

export NO_MSGFMT=1
make all

assuming that you only need to install the English interface.

If you get an error like referring to expat.h then you will need to build expat using the following commands

curl -O
tar xzvf expat-2.0.1.tar.gz
cd expat-2.0.1
make check
sudo make install
cd ..
source /etc/profile

To make sure that git is installed and working, trying running git from the command line.

Setting up a remote repository

In my case, I was interested in setting up our lab server (OSX 10.3) to properly host git repositories. First, install git on the server. Next, add the following to  /etc/profile, which is a handy script to make repository creation easy. The script is great and is from here.

if [ -z $1 ]; then
echo "usage: $FUNCNAME project-name.git"
mkdir $gitdir
pushd $gitdir
git --bare init
git --bare update-server-info
chmod a+x hooks/post-update
touch git-daemon-export-ok

After creating the folder /Library/WebServer/Documents/git you can just run newgit repository.git to make an accessible repository.

Here's an important step: make sure that /etc/profile properly loads the /usr/local/bin directory (see above). When you push/pull/clone data from your server, things will not go smoothly and will get errors like git-receive-pack: command not found or git-upload-pack: command not found.

Installing gitweb

Git includes a handy .cgi program for viewing your repositories through a browser. It's quick to install assuming you have apache setup with mod_perl installed and it's setup to serve .cgi files. Checkout the gitweb directory in the git source folder after you built git earlier (you didn't delete it yet, right?)

At this point you can use git normally on your remote host. Here are some hastily written examples:

Creating a repository from a directory of existing files

git init
git add .
git commit -m "first commit"

Creating a new repository

git init
(create files, write code)
git add .
git commit -m "first commit"

Putting your code on your server

newgit PROJECT.git
git push USERNAME@YOURSERVER:/Library/WebServer/Documents/git/PROJECT.git master

Pulling code from your server

git clone USERNAME@YOURSERVER:/Library/WebServer/Documents/git/PROJECT.git

Here are a few additional references to help get started (1, 2, 3, 4, and 5).


Wednesday, March 19th, 2008

After a bit of work the past few days, we turned on the new version of the website today. Hopefully most of the kinks are worked out but there may be some link weirdness. I made sure to modify the URL rewrite rules to keep the very few external links working, but if you find something broken let me know. Check out the new gallery theme.

Importing Drupal to WordPress

Tuesday, March 18th, 2008

Drupal is great software but is a bit much for a simple website, and it's small user base relative to WordPress makes it difficult to find high quality plug-ins. The final straw was that Drupal is really slow on my current host (Dreamhost) because it makes tons of database queries and Dreamhost keeps my database on a separate server to keep costs down.

I decided to switch to WordPress last night and managed to transfer all of the data in a couple hours of work. The key was this sql script to transfer everything, which is a little bit old and required installing WordPress 2.0, importing, and then upgrading to the latest version because they changed the table format in 2.2 or so. Now I'm just working on cleaning up some old posts that didn't transfer cleanly (no good wiki syntax in WordPress, I probably should have switched it awhile ago though) and am happy so far.


Tuesday, March 18th, 2008

We've been living in Zurich for about 10 days so far and it's awesome. My wife's work is about a 25 minute walk and mine is about 5, which is really nice compared to home. So far the weather's been a little chilly but not too bad. There was a little bit of snow one day last week, which was awesome.

Last weekend we went to Leukerbad. Public transportation here runs like clockwork. We took a big train, little train and bus and all of them left within 30 seconds of their scheduled times. Also, they allow plenty of time for transfers, which means that you won't get stuck in the middle of nowhere but also having a book handy is key. Speaking of which, the people we're renting from left an absolutely hilarious book called Xenophobe's Guide to the Swiss, and I'm tempted to get the California edition to see what's said.In Leukerbad we rode a cable car up to the Gemmi pass and rode sleds up there for a few hours. After that we sat in the way overcrowded hot springs for awhile to warm up, before eating some awesome Hawaiian style rösti with pineapple and cheese on top. The next day I went snowboarding on Torrenthorn, which is about 9800 feet. I forgot my snowboarding pants so instead went in my fleece pajama bottoms (the cheapest pants were 200-300 CHF!) which actually worked pretty nicely.

It was the first time I've used T-bar lifts, and I managed to eat it the first time. Using it on a snowboard was tricky because you need to stick it between your legs so that you can go up the hill facing sideways. I saw a few snowboarders fall off part way up and then need to scurry out of the way before they were run over by the next people. Craziness. Overall pretty cool though.

Probably most importantly, I just uploaded some photos.