Installing GitList for Local Repos

Vincent Ellis
Vincent Ellis
Share

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

Frequently Asked Questions (FAQs) about Installing GitList for Local Repos

What are the prerequisites for installing GitList on my local server?

Before you can install GitList on your local server, you need to have a few things set up. First, you need to have a server running PHP 5.3.3 or higher. You also need to have Git installed on your server. If you’re using a Windows server, you might find WampServer to be a useful tool, as it allows you to manage your server and its services easily. Lastly, you need to have Composer installed. Composer is a tool for dependency management in PHP, and GitList uses it to manage its dependencies.

How do I clone the GitList repository?

Cloning the GitList repository is a straightforward process. You simply navigate to the directory where you want to install GitList, and then run the command git clone https://github.com/klaussilveira/gitlist.git. This will create a new directory called ‘gitlist’ and download the GitList repository into it.

How do I configure GitList?

Configuring GitList involves creating a config.ini file in the config directory. This file should contain the path to your repositories and the client to use. You can also specify other options, such as the date format, the file size limit, and whether to show repository statistics.

How do I install the dependencies using Composer?

To install the dependencies using Composer, you need to navigate to the GitList directory and run the command composer install. This will download and install all the necessary dependencies.

How do I set up the .htaccess file?

The .htaccess file is used to configure the Apache server. You need to create a .htaccess file in the GitList directory and add the necessary configuration. The exact configuration depends on your server setup, but generally, you need to enable the rewrite module and set the RewriteBase to the path of your GitList installation.

How do I access GitList after installation?

After you’ve installed and configured GitList, you can access it by navigating to the URL of your GitList directory in your web browser. For example, if you installed GitList in the ‘gitlist’ directory on your local server, you would navigate to http://localhost/gitlist.

Can I use GitList with other servers besides Apache?

Yes, you can use GitList with other servers such as Nginx or IIS. However, the configuration might be different. For example, instead of using a .htaccess file, you would use a configuration file specific to your server.

How do I update GitList?

To update GitList, you need to navigate to the GitList directory and run the command git pull. This will download the latest changes from the GitList repository. After that, you need to run composer install to update the dependencies.

Can I customize the look and feel of GitList?

Yes, you can customize the look and feel of GitList by editing the CSS files in the public directory. However, keep in mind that your changes might be overwritten when you update GitList.

What should I do if I encounter problems during the installation?

If you encounter problems during the installation, you should check the error messages for clues about what went wrong. You can also check the GitList issues on GitHub or ask for help on the GitList mailing list.