1. We have moved from vBulletin to XenForo and you are viewing the site in the middle of the move. Though the functional aspect of everything is working fine, we are still working on other changes including the new design on Xenforo.
    Dismiss Notice

cgit: A Web Interface for Git

Discussion in 'Engineering Concepts' started by pradeep, Sep 4, 2012.

  1. pradeep

    pradeep Team Leader

    Joined:
    Apr 4, 2005
    Messages:
    1,646
    Likes Received:
    86
    Trophy Points:
    0
    Occupation:
    Programmer
    Location:
    Kolkata, India
    Home Page:
    Git is popular distributed version control system, it was developed by inventor of Linux, Linus Torvalds. Git has been gaining huge popularity in the ope-source community as well as in the corporate world due to it's distributed nature and efficiency.

    I had a written a few articles on Git to in introduce people to Git, [THREAD=27216]Introduction to Git VCS[/THREAD] and [THREAD=27305]Git VCS - Cloning & Workflow[/THREAD], you should read those too if you are completely new to Git.

    In this article we'll be looking a installing a popular web interface for git repositories - cgit. cgit is a fast web interface for Git repositories, it is better than gitweb - another web interface for git - which is written in Perl, primarily because it's written in C and runs as a binary.

    Installing cgit



    I am assuming you already have git installed, here is the flow of commands that need to be issued to get the stable source of cgit.

    Code:
    # git clone git://hjemli.net/pub/git/cgit
    # cd cgit
    # git submodule init
    # git submodule update
    
    Now, we'll need to customize the install like the directory where CGI files would be installed, the config for the cgit binary, etc. Following are the defaults for cgit:

    Code:
    CGIT_SCRIPT_NAME = cgit.cgi
    CGIT_SCRIPT_PATH = /var/www/htdocs/cgit
    CGIT_CONFIG = /etc/cgitrc
    CACHE_ROOT = /var/cache/cgit
    SHA1_HEADER = <openssl/sha.h>
    GIT_VER = 1.6.0.3
    GIT_URL = http://www.kernel.org/pub/software/scm/git/git-$(GIT_VER).tar.bz2
    
    In case you want to change any of these (most likely you will, like I did), create a cgit.conf file in the same directory with variables you want to modify and their appropriate values, mine looks something like this:

    Code:
    CGIT_SCRIPT_PATH = /var/www/html/cgit
    CGIT_CONFIG = /home/root/cgitrc
    CACHE_ROOT = /var/cache/cgit
    
    Now, we'll need to compile & install cgit.

    Code:
    # make
    # make install
    
    Next we would need to add some configuration in Apache for cgit to run.

    Code:
    <Directory "/var/www/html/cgit/">
          AllowOverride None
          AddHandler cgi-script .cgi
          Options +ExecCGI
          Order allow,deny
          Allow from all
    </Directory>
    
    Next comes creating and population cgitrc file with the list of repositories & their path. Look at the following cgitrc file, it's pretty simple.

    Code:
    local-time=1
    root-desc=Pradeep Local Dev
    enable-index-links=1
    enable-log-filecount=1
    enable-log-linecount=1
    snapshots=tar.gz tar.bz zip
    
    ## List of repositories
    
    repo.group=Python
    repo.url=Python-DBus
    repo.path=/var/www/git/python_dbus.git
    repo.desc=Python Programs to access DBus
    repo.owner=Pradeep
    
    repo.group=Perl
    repo.url=RoundRobinShared
    repo.path=/var/www/git/roundrobin_shared.git
    repo.desc=Test Programs for Shared Mem
    repo.owner=Pradeep
    
    repo.group=Perl
    repo.url=KidsMaths
    repo.path=/var/www/git/kids_maths.git
    repo.desc=Kids Maths Programs
    repo.owner=Anjali
    
    repo.group=ASP
    repo.url=Slambook
    repo.path=/var/www/git/slambook.git
    repo.desc=ASP learning Code
    repo.owner=Pradeep
    
    That's it, restart Apache and go to the URL http://<your-server-ip>/cgit/cgit.cgi.

    References



    http://hjemli.net/git/cgit/tree/README
     

Share This Page