Insanely Awesome Web Interface for Your Git Repos

Almost 80-90 people visit How To: Install and Configure GitWeb everyday in search of setting up a web interface for their git repositories. Though gitweb is nice, it’s a bit painful to setup and the web interface is not that appealing. The other day I received this email from Klaus Silveira

Hello Kulbir,
I saw your article about installing Gitweb and i decided to send this shameless self-promotion. Maybe you could try my open-source project, GitList https://github.com/klaussilveira/gitlist

I’m looking for beta testers and supporters. FLOSS. 🙂

So, I thought I’ll just give it a try. Today, I got it working and was blown away by the amazing interface! It’s almost like a super simplified version of GitHub. I was so impressed that I immediately setup a demo website at git.gofedora.com for others to look at and fall in love :-)Another good thing about GitList is that it’s very simple to setup. Below is a step by step process to install and configure GitList to expose your public Git repositories to the internet.

What You Need?

You need the following packages before you can setup GitList.

Installing Required Packages

Most modern operating systems have the above mentioned packages installed by default. Even if you don’t have them already, you can use your OS package manager to install them quickly. To install on Fedora/RedHat/CentOS using yum, use the following command

[root@whitemagnet.com ~]$ yum install php git httpd

For Ubuntu/Debian, use the following command

[root@whitemagnet.com ~]$ apt-get install php git apache2

Assumptions

For setting up GitList, I am assuming the following directory paths and other variables.

  • Path to public Git repositories : /home/saini/code/public/
  • Path to Apache document root : /var/www/html/
  • Path to Git executable : /usr/bin/git (Use “which git” to find out for your OS)
  • Web URL for browsing git repos : mygit.example.com/gitlist/

Installing and Configuring GitList

Follow the following simple steps to install and configure GitList.

Step 1 : Clone GitList repository from GitHub to /var/www/html/gitlist/

[root@whitemagnet.com ~]$ cd /var/www/html/
[root@whitemagnet.com html]$ git clone git://github.com/klaussilveira/gitlist.git gitlist

Step 2 : Create cache directory and make it globally writable

[root@whitemagnet.com ~]$ cd gitlist
[root@whitemagnet.com gitlist]$ mkdir cache
[root@whitemagnet.com gitlist]$ chmod 777 cache

Step 3 : Configure GitList using config.ini

Open the config.ini (in gitlist directory) and set the option properly. Refer the sample shown below.

[git]
client = '/usr/bin/git' ; Your git executable path
repositories = '/home/saini/code/public/' ; Path to your repositories (with ending slash)
 
[app]
baseurl = 'http://mygit.exmaple.com/gitlist' ; Base URL of the application (without ending slash)

Step 4 : Make sure your Apache can read your .htaccess file in gitlist directory

GitList utilizes Apache’s mod_rewrite module to  provide nice URLs. Make sure your Apache is configured to read .htaccess from the gitlist directory. Open your Apache config file (generally located at /etc/httpd/conf/httpd.conf or /etc/apache2/ports.conf) and look for the following

<Directory "/var/www/html">

In this segment, make sure you have AllowOverride All as below.

<Directory "/var/www/html">
# Other lines omitted
AllowOverride All
# Other lines omitted
</Directory>

Step 5 : Reload or restart Apache daemon if needed

[root@whitemagnet.com ~]$ apachctl -k restart (or apache2ctl -k restart for Ubuntu/Debian)

Step 6 : Get some sample repositories in your public repo directory

Get some sample repositories in your public repo directory from GitHub.

[root@whitemagnet.com ~]$ cd /home/saini/code/public/
[root@whitemagnet.com ~]$ git clone git://github.com/kulbirsaini/intelligentmirror.git
[root@whitemagnet.com ~]$ git clone git://github.com/kulbirsaini/Railscasts-Sync.git
[root@whitemagnet.com ~]$ git clone git://github.com/zilkey/active_hash.git

That’s all! Now, go to http://mygit.example.com/gitlist to discover your public git repos via a cool web interface! Leave a comment if you face any issues.

 

26 thoughts on “Insanely Awesome Web Interface for Your Git Repos

  1. Just out of curiosity, did you try it with very large git repo ? Like the kernel or libreoffice (which has over 8000 commits).

  2. Thanks for writing about GitList. It looks very good. Not to steal thunder from GitList but have you looked at cgit? It’s another nice webinterface for Git. It’s not as slick as GitList but works very well. It’s available in the Fedora repo’s or at http://hjemli.net/git/cgit/ Now I’m off installing GitList with your steps. Thanks!

  3. Kulbir, this is amazing. Thanks for sharing it. I’ve gone ahead and setup my own local instance of GitList. It feels almost like I have my own little Github now. I’m sure the project will continue to mature with time and become really a great way to host your own projects.

  4. @pingou Doesn’t scale well. Could show stats from Linux and Libreoffice Core but the process is always killed while trying to parse all commits. Too many of them. But nifty to small scale repos.

    @Pieter Thanks for mentioning cgit. I’ll have a look at the installation steps and compare both.

    @Basil That was exactly my reaction when I first saw it 😀

    @Bash Though Gitlabhq looks nice and more feature rich compared to GitList, it’ll be a bit of a task to setup Gitlabhq. This post was targeted at novice users who want their own web interface for their git repos but at minimal cost.

  5. Really nice interface but as compared to the gitweb but..
    I’m facing problem when I click at repository
    _______________________________________________________
    Not Found

    The requested URL /gitlist//tree/master/ was not found on this server.
    _______________________________________________________

  6. I am using Ubuntu 10.10 with Apache 2.2.16
    ==========================================

    Getting Source

    $ cd /mnt/Core/रो/bog/git/
    $ git clone git://github.com/klaussilveira/gitlist.git
    $ cd gitlist
    $ mkdir cache
    $ chmod 777 cache

    ==========================================
    Configure stuffs and Repo
    Then configured config.ini as requried
    Added simlink to few of my projects

    ==========================================
    Configuring apache2
    here is my /etc/apache2/ports.conf
    _________________________________________________

    # If you just change the port or add more ports here, you will likely also
    # have to change the VirtualHost statement in
    # /etc/apache2/sites-enabled/000-default
    # This is also true if you have upgraded from before 2.2.9-3 (i.e. from
    # Debian etch). See /usr/share/doc/apache2.2-common/NEWS.Debian.gz and
    # README.Debian.gz

    NameVirtualHost *:80
    Listen 80

    # If you add NameVirtualHost *:443 here, you will also have to change
    # the VirtualHost statement in /etc/apache2/sites-available/default-ssl
    # to
    # Server Name Indication for SSL named virtual hosts is currently not
    # supported by MSIE on Windows XP.
    Listen 443

    Listen 443

    AllowOverride All


    ____________________________________________
    ========================================
    Adding gitlist to /etc/apache2/conf.d
    I did try with symlink to the /var/www/gitlist also but nothing changed


    $ cd /etc/apache2/conf.d
    $ touch gitlist

    # edit gitlist
    # configure file is like this
    _______________________________________________

    Alias /gitlist /mnt/Core/रो/bog/git/gitlist

    AllowOverride All
    Options FollowSymLinks +ExecCGI
    AddHandler cgi-script .cgi


    ______________________________________

    Restarted the apache
    $ sudo service apache2 restart
    It show the repository but it cannot be browsed!

    ++++++++++++++++++++++++++++++++++++
    :/ any thing that i missed!

    1. this is probably several months too late to help Rho, but in case anyone else comes along and reads this, with a default install of Apache on Ubuntu I had to enable the rewrite mod:
      sudo a2enmod rewrite

  7. I’ll suggest moving that /etc/apache2/conf.d/gitlist to /etc/apache2/conf.d/gitlist.conf because Apache includes only *.conf files from conf.d directly by default. At least, that’s the case on Fedora/CentOS. Try this change and let me know if it still doesn’t work.

  8. I got tired of simlink and alias so i pasted the repo in /var/www/gitlist
    cleaned my earlier configuration ..
    then edited /etc/apache2/ports.conf.
    but still not working
    😐

  9. I guess you should first attempt to install this within your document root, i.e. /var/www/html/gitlist/. If it works there, then try moving it to a different location.

  10. I got the web interface and everything running just fine but when I’m having trouble using git period lol. I am relatively new to it and would like to use my server as a development repository and then push releases to github.

    I ran everything defaults like your tutorial explains.
    Repo directory: /home/ruthik/code/public
    WWW directory: /var/www/gitlist

    Like I said the WWW works just fine. I am using an IP address to hit the server so would I type in http://(ip-address)/(repoName)? I’ve tried using multiple locations and nothing seems to work. Eclipse just returns that there was an ls error. Any help is great help! Thanks for the great tutorial though. It really is like a mini github for myself =)

  11. This is very nice! 🙂 I did get it working and all is well. However, I just spent 2 days setting up gitolite and redmine working smoothly with ssh (hey I’m a tad new to git). Now that I got that working I went to change the repositories path to a directory in /var/lib and I get permissions problems. It is not allowed to see /var/lib obviously. How do I go about allowing it? I don’t want to simply chmod 777 but I would like to get this working 🙁 Thanks in advance!

  12. Ruthik,
    GitList doesn’t need to write anything to your git repos ever. So, you won’t need to chmod 777. If your repos are public, you can give read permissions.

  13. Ah, I see. Thanks for such a quick reply! I think I am doing something wrong. I got rid of Redmine (way too much overkill) and installed GitLab. It works flawlessly. The respositories folder is set to /home/git/repositories in the config.ini file (/var/www/gitlist/config.ini). It reads all of the repositories but when I click one it says:

    The requested URL /gitlist/repositoryname.git/tree/master/ was not found on this server .

    I found this thread -> https://github.com/klaussilveira/gitlist/issues/2 so I know it’s possible. It looks like he already has it set up and working. I found out that it is searching /var/www/gitlist/repositories. I set up a symbolic link from /home/git/repositories to /var/www/gitlist/repositories and it now says permission denied. I know I am making this way more complicated than it should be. How can in I simply have gitlist read /home/git/repositories for the repos and its contents?

  14. Hi,

    I’m not able to view git repo instead it is showing index.php file.
    I followed all the steps.
    Am i missing something. I’m newbie to this.

    Ranjan.

  15. Hi, please help me, I have a PHP fatal error when run http://localhost/gitlist,
    thanks,

    PHP Warning: require(vendor/autoload.php): failed to open stream: No such file or directory in /var/www/gitlist/index.php on line 8, referer: http://localhost/
    PHP Fatal error: require(): Failed opening required ‘vendor/autoload.php’ (include_path=’.:/usr/share/php:/usr/share/pear’) in /var/www/gitlist/index.php on line 8, referer: http://localhost/

  16. Hi,
    My gitlist installation does not seem to use the directory specified by the repositories property in the config.ini file. it always looks for the git projects in /{install-dir-under-apache}/{git-projname} ..

    what am i doing wrong ?

    ;-p r a b u!

  17. I am getting;

    Oops! Unable to execute command: ls-tree -l master

    After selecting a repo, a longer Opps when selecting RSS.
    I see all my repos OK though. Any ideas?

  18. I’m getting an include error on ‘vendor/autoload.php’ which I figured was because I didn’t have composer installed. Trying to install composer the way the site tells me doesn’t work either as I get a

    php composer.phar install
    Loading composer repositories with package information
    Installing dependencies from lock file
    Your requirements could not be resolved to an installable set of packages.
    
      Problem 1
        - Can only install one of: symfony/symfony 2.1.x-dev, symfony/symfony v2.1.0-BETA3.
        - don't install symfony/symfony 2.1.x-dev|don't install symfony/twig-bridge v2.1.0-BETA3
        - Installation request for symfony/event-dispatcher == 2.1.9999999.9999999-dev -> satisfiable by symfony/symfony 2.1.x-dev.
        - Installation request for symfony/twig-bridge == 2.1.0.0-beta3 -> satisfiable by symfony/symfony v2.1.0-BETA3, symfony/twig-bridge v2.1.0-BETA3.

    Not sure what to do about that. Can I install these packages separately instead of using composer?

Comments are closed.