Installing GitList for Local Repos
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