Jeff Mesnil

(Updated) Gitweb Setup on Mac OS X

Git logo + Apple logo

I wrote a post about setting up Gitweb on Mac OS X 2 years ago. Today I was reading it again to setup gitweb on another Mac and the steps have slightly changed.

It assumes that Git is installed in /usr/bin (otherwise, modify the bindir property accordingly).
You just need to modify GITWEB_PROJECTROOT to point to the root of your Git projects.

To install gitweb (from Git 1.7.2.1) on Mac OS X 10.6.4, the steps are now:

# define the projects root
export GITWEB_PROJECTROOT="/Users/jmesnil/Git/"
 
# retrieve the latest version of git
git clone git://git.kernel.org/pub/scm/git/git.git
cd git/
 
# install gitweb.cgi
sudo make GITWEB_PROJECTROOT=$GITWEB_PROJECTROOT \
     GITWEB_CSS="/gitweb/gitweb.css" \
     GITWEB_LOGO="/gitweb/git-logo.png"  \
     GITWEB_FAVICON="/gitweb/git-favicon.png"  \
     GITWEB_JS="/gitweb/gitweb.js" \
     bindir=/usr/bin \
     gitwebdir=/Library/WebServer/CGI-Executables/gitweb \
     install-gitweb
 
# move the static files to the proper folder
mkdir -p /Library/WebServer/Documents/gitweb
cd /Library/WebServer/
mv CGI-Executables/gitweb/static/* Documents/gitweb

and go to http://localhost/cgi-bin/gitweb/gitweb.cgi

Using Git

Git logo

I have switched from Subversion to Git a few months ago as the version control system for all my private projects and some of my public projects and I’ve not looked back.

The setup can not be simpler (git init in the project directory) and gitweb is easy to setup to browse the repository and its history.

Git is simple to use, simple to learn (with good in-depth and user documentation) and fast.

When I am learning new languages or frameworks, I tend to use an exploratory mode made of trials and errors. I found that the workflow of Git (simple branch creations and merges, stashes, reset) corresponds better to this approach than Subversion (which works best with an upfront design).

One of its great features compared to Subversion is that it distinguishes between the author and the committer.
In Subversion, when an user submits a patch and I apply it, I’m both the committer and the author (I mention the user in the commit message and/or the header’s files but as far as Subversion is concerned, the user does not exist).
In Git, when I apply the patch, I’m only the committer, the user is the author of the commit and will remain so in the history, in git blame, etc. (as an example, here is a commit where I am the committer and Clay McClure is the author). This feature is very important for open source projects where your reputation comes from the code you write, even if it is only through patches.

The only area where Git is lacking behind Subversion is the tools. However I don’t mind using a shell and Vim for most of the simple and frequent tasks. For advanced ones, gitk and Textmate are good enough for my needs.

I continue to use Subversion for my professional work but for my personal projects, Git is now my main choice (the only exception being Eclipse projects but as soon as there is a Git plug-in which is good enough, I’ll switch too).

Gitweb setup on Mac OS X

Update: I have written a new post for an updated setup with a more recent version of Git.

This post is for future references since I had to slightly adapt what is written in the INSTALL file to run Gitweb on my MacBook.

Assuming all my Git projects are in /Users/jmesnil/Work/ and I’ve already installed Git using MacPorts (sudo port install git-core), the steps to create gitweb.cgi is:

cd ~/Work
# retrieve the latest version of git
git clone git://git.kernel.org/pub/scm/git/git.git
cd git/
make GITWEB_PROJECTROOT="/Users/jmesnil/Work/" \
     GITWEB_CSS="/gitweb/gitweb.css" \
     GITWEB_LOGO="/gitweb/git-logo.png"  \
     GITWEB_FAVICON="/gitweb/git-favicon.png"  \
     bindir=/opt/local/bin
     gitweb/gitweb.cgi
 
# CGI scripts are located in /Library/WebServer/CGI-Executables
mkdir -p /Library/WebServer/CGI-Executables/gitweb
sudo cp gitweb/gitweb.cgi /Library/WebServer/CGI-Executables/gitweb/
 
# And the other resources are in /Library/WebServer/Documents/
mkdir -p /Library/WebServer/Documents/gitweb
sudo cp gitweb/gitweb.css gitweb/git-logo.png gitweb/git-favicon.png \   
   /Library/WebServer/Documents/gitweb/

Once everything is copied to the right place, Gitweb is up and running: http://localhost/cgi-bin/gitweb/gitweb.cgi?

jmx4r moved to git

I use Subversion for my daily work (and CVS before that) but I’ve never used a distributed VCS before. One of my ex-colleagues, Marc, explained to me all the advantages of these systems but I never took the time to play with them.
With all the increasing noise about Git and Mercurial, I’m now curious to learn more about it.

Since I learn better by practicing, I moved one of my little projects, jmx4r, from Subversion to Git and hosted it on GitHub.

I don’t use jmx4r at the moment and I don’t plan to develop it more (less features is the new black). However, if you have requests for a new feature or enhancement (or bugs), do not hesitate to fill an issue on the tracker.
Or better, clone the Git project:

git clone git://github.com/jmesnil/jmx4r.git

and start hacking it!

P.S.: With the recent release of JRuby 1.1, I also checked that the latest version of jmx4r had no regression.
Congratulation to the JRuby team for the performance boost since version 1.0!