Jeff Mesnil

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?

Posted by on July 31, 2008

Comments

  • Jamie Hill says:

    Hi, this was all going so smoothly until I received a “404 – No projects found” error.

    I used the following config and dropped some git directories into /Users/jamie/git

    make GITWEB_PROJECTROOT=”/Users/jamie/Sites/git/” GITWEB_CSS=”/gitweb/gitweb.css” GITWEB_LOGO=”/gitweb/git-logo.png” GITWEB_FAVICON=”/gitweb/git-favicon.png” bindir=/usr/local/bin gitweb/gitweb.cgi

    I have changed permissions left, right and centre but with no luck. Any ideas that could help me out as the docs are somewhat sparse :)

    Thanks in advance.

  • Jeff Mesnil says:

    Hi Jamie,

    I’ve you got the “404 – No projects found” it means that everything works but Gitweb does not find any Git project in your dir.

    Stupid question: in your comment, you said you put git projects in /Users/jamie/git but your make command uses /Users/jamie/Sites/git/. Is it a typo or did you use 2 different directories by mistake?

    jeff

  • Jamie Hill says:

    Hi Jeff,

    Thanks for your response, and yes that was a typo in my comment. I’ll be dammed if I can get the thing working, just keep getting the same error after hours of trying. I am new to git (a bit of an svn veteran).

    Silly question but how do you create the repositories in your root path as I tried copying one of my existing “gitified” folders in there which didn’t work. Also I created a new directory called “tester.git”, cd’d into it and ran “git –bare init” in there, I then did a push to the new repository from a completely separate one.

    I feel like I’m missing something as I don’t really understand the difference between a normal repository and one made with “git –bare init”. If you could point me in the right direction it would be much appreciated.

    Thanks again,

    Jamie

  • Jeff Mesnil says:

    Hi Jamie,

    fyi, the permissions for my Work directory is drwxr-xr-x. It might be worth a look to check your dir has the same permissions.

    In my Work dir, I create Git project in the simplest way:

    cd Work
    mkdir foo
    cd foo
    git init
    

    The difference between a regular and a bare Git repo is that the bare repo contains only Git metadata not the project files. In short, you can’t work on a bare repo (there is no files to edit). Bare repositories are used as the “public” repositories from which you clone your “private” repo and push changes to it.

    hope it helps, jeff

  • Jamie Hill says:

    Just got this working on my laptop like a charm! …I don’t know what is different from my desktop machine other than the laptop being Intel and the desktop being PPC.

    Thanks for your help, I get the difference between bare repositories and working/private ones now… kind of obvious when you know.

  • Jamie Hill says:

    Just incase anyone else make my silly mistake. My home directory didn’t have executable access and therefore the web server couldn’t enter my home directory. The solution was to “chmod a+x ~/” .

  • drew says:

    Hi,

    I had the same issue as Jamie Hill, I ran the make command, copied the cgi over to the sites folder and got ’404 – no projects found’ when browsing. I think it was because the cgi was already made in my source tree (maybe I built it before?!), but using the default parameters with the projects stored in /pub/git/ When creating the cgi the make command reported it was up to date, so I think it didn’t overwrite the settings.

    Thanks for the hints. HTH

  • Aron Ahmadia says:

    Thanks Jeff, that worked like a charm.

  • Irfan says:

    Everything worked like a charm but I am unable to see list of my projects on main page. However, I see the list of projects when I click on the orange TXT button.

  • Jeff Mesnil says:

    @Irfan mmhhh, this sounds like a permission problem. You could try to chmod a+x your projects directory to see if it works.

  • Irfan says:

    I fixed the issue by updating the $GIT variable to /usr/local/git/bin/git in CGI script. This is the default install location of git. Its working fine now, Thanks :)

  • Mason says:

    Thanks Irfan this fixed me too. I used which git to specify the bin in the script, but the script wants the containing folder. I guess it uses the old git-commands format.

  • Dan says:

    This worked fine for me, thanks!

    I have two small issues that might be of interest, given what I’ve read above.

    1). The entries in the website lack a ‘git’ link. I’ve noticed such a link on http://git.kernel.org/gitweb.cgi for example. This is quite convenient.

    2) A solution would be to add some text at the top of the page (again, the git.kernel.org site has such text). Does anyone on this thread know how to add text to the top of the page?

  • David says:

    I was getting the same 404 error. In one of the tutorials there was a mention about creating a global file /etc/gitweb.conf. I forgot and it was taking over all settings so after removing it and setting correct $GIT and $projectroot all work like a charm!

  • shrop says:

    Thanks much! Worked like a charm on Leopard Server too.

  • [...] Use code repository on your computer By fdiblen 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/ Source:http://jmesnil.net/weblog/2008/07/31/gitweb-setup-on-mac-os-x/ [...]

  • Thanks for the doc, I did a sum up of my gitweb installation here http://ruready.tumblr.com/post/1008951976/gitweb-configuration-easy-way

    Benoit

  • Brad C. says:

    Thanks, Irfan. Your fix worked for me also.

  • Comments closed