I was reading "Pro Git" by Scott Chacon and was on the section about "git instaweb". This is where you can run gitweb, a cgi script that comes with git, locally or on a server. I have successfully gotten gitweb up for my personal git repos on my remote server. I use it all the time. I was curious if I could get it working locally, for friends who prefer a visual tool to see their git logs, commits, etc.
I cd into a local repo (you have to cd into the .git folder of the app to get the desired view):
cd /code/app/.git
and run the instaweb command (note: I'm on a macbook pro that already has ruby installed, hence my choice of using webrick instead of the default lighttpd):
git instaweb -d webrick --start
I tried the command without the "--start" command and it kept trying to seek a browser. I tried "-b firefox", "-b Firefox", "-b /Application/Firefox.app/MacOS/firefox-bin", etc and they all failed. I found the "--start" suggestion on StackOverflow.com
Once I ran this command, I could see the git log, commits, diffs, etc in gitweb for my local changes. What this will do is run the daemon on port 1234 of localhost. If you open your browser of choice and go to http://localhost:1234 then you will see gitweb for the git repository you ran the command in.
The catch: you will have to stop the process manually. On my macbook, I ran the following command:
kill -9 `ps -aux | grep webrick | grep -v grep | awk '{print $2}'`
This will pass the id of the local process running webrick to "kill -9" and kill the process. ("grep -v grep" excludes the grep command you just ran from the processes returned in the ps query)
Note: I personally use "git log --graph", gitk, gitx, or other tools for this, usually. Just thought it was a good addition to my git toolset.
Posted
Sep 26 2009, 08:53 PM
by
Jason Meridth