Installing GitList for Local Repos

Tweet

GitHub is a great solution for code collaboration and repository management, but some individuals and companies don’t feel secure hosting their code in the cloud and instead prefer to maintain an intranet. Making your repositories available in a local intranet is pretty easy, but having a nice interface to interact with those repositories, making collaboration between teams easier, is not that simple.

Git provides a web interface to solve this problem, gitweb, but it’s not an elegant and modern solution. It’s hard to see what has changed, who did it, and when it happened. Also, browsing through the working tree is cumbersome. There are other solutions available, but some are too hard to install or, again, hard on the eyes. I recently discovered GitList, a free and open source Git repository viewer. It’s interface resembles GitHub a lot but aims to keep everything simple and clear.

In this article I’ll guide you through the process of setting up your own Git repository viewer. Don’t worry, it won’t hurt and it’s quicker than installing WordPress!

Environment

For this guide I’m assuming that you are working on a Debian-based Linux distro, but GitList will work with anything. Basically, you need:

  • Apache with mod_rewrite or Nginx
  • Git
  • PHP 5.3+

If you don’t have these installed, open a terminal and run:

sudo apt-get update
sudo apt-get install php5 apache2 git

I’ll also make the following assumptions regarding your environment:

  • Path to your Git repositories: /home/bob/code
  • Path to Apache document root: /var/www
  • Path to Git executable: /usr/bin/git
  • Your Apache root URL: http://localhost

Your Git repositories will be accessed by the Apache user, so you need to apply proper access permissions:

sudo chmod -R 744 /home/bob/code

Installing and Configuring GitList

First, download GitList. You can choose either the latest stable version or the master version, but keep in mind that the master version may have bugs since developers are actively working on it. After choosing your package, uncompress it to your Apache document root inside a folder called gitlist.

Now to configure GitList! Rename the config.ini-example file to config.ini and open it with a text editor and make sure it looks like this:

[git]
client = '/usr/bin/git' ; Your git executable path
repositories = '/home/bob/code/' ; Path to your repositories

; You can hide repositories from GitList, just copy this for each repository you want to hide
; hidden[] = '/home/bob/code/SecretProject'

[app]
baseurl = 'http://localhost/gitlist' ; Base URL of the application

; If you need to specify custom filetypes for certain extensions, do this here
[filetypes]
; extension = type
; dist = xml

There’s just one step left: we have to create a folder inside /var/www/gitlist with the name cache and give it the proper permissions. So:

cd /var/www/gitlist
mkdir cache
chmod 777 cache

Now go to http://localhost/gitlist and check it out.

Help! Page Not Found!

GitList uses Apache’s mod_rewrite to create pretty URLs. So if the page isn’t found, make Apache has mod_rewrite enabled by running:

sudo a2enmod rewrite

Also, make sure Apache is able to read the .htaccess file from the GitList directory. An .htaccess file is used for overriding and adding new rules to Apache directories. Open up your default Apache website config file (usually located in /etc/apache2/sites-enabled/000-default) and look for the following:

<Directory /var/www/>
	Options Indexes FollowSymLinks MultiViews
	AllowOverride None
	Order allow,deny
	allow from all
</Directory>

Change the AllowOverride option from None to All. Save your changes and restart Apache.

sudo /etc/init.d/apache2 restart

Customizing

The GitList interface was built using Twitter Bootstrap and uses LESS. The LESS files are available under web/less. A makefile is provided, so all you have to do is customize the LESS files based on your taste, run make under the web directory, and the final CSS will be generated. Of course, you do have to have lessc installed, which can be done quite easily by running npm: npm install less

GitList is powered by the Twig template engine, and all templates are available under views. In order to understand what’s going on, I recommend you read this tutorial. Don’t forget to clean the contents of the cache folder after modifying .twig files!

Image via Fotolia

Free book: Jump Start HTML5 Basics

Grab a free copy of one our latest ebooks! Packed with hints and tips on HTML5's most powerful new features.

  • http://www.maltblue.com Matthew Setter

    Hi Vincent,
    Nice post about a good app. I’ve just installed it and had a bit of a play around with it. Pretty sweet indeed. It’d be great to have a quick note about using composer if cloning a copy of the repo, but otherwise, great post.
    Matt

    • Vincent

      Well, the developers are quite specific on using the archive from the official website instead of cloning the repo. This is great for end users, because you just need to extract the damn thing.

      If you are a developer, you can check the build.xml Apache Ant script and inspect the build steps. The most important ones being “prepare” and “package”.

  • Amy Stephen

    Vincent – point readers to http://gitlist.org/ (instead of directly to the github repository). That is where the downloads exist. Otherwise, what Matthew is pointing out about composer is an issue. The files at http://gitlist.org/ are bundled to avoid that complexity.

    Thanks for the article, very helpful.

  • http://www.mirosvrtan.me/ Miro Svrtan

    Hi,
    Tnx for a great suggestion, just pulled repo and I’m loving it!
    Small suggestion: line with baseurl is not needed in config.ini

  • barney

    Vincent,
    I’m certain that what you have written is very much adequate for various Linux distros. But some of us are constrained to use other OSes. Whether I like it or not, I’m restricted to Windows. ‘Twould be nice if you’d address that condition – most of your description is pretty much useless for that OS.

  • juni

    Awesome!!! I’m at one of those companies that is always so protective of everything… This helps a ton.

  • Isidro Merayo Castellano

    Nice tutorial!!!
    I change to 755, without “Oops! There are no GIT repositories in XXX”