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!
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
- 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:
- Path to Apache document root:
- Path to Git executable:
- Your Apache root URL:
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
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>
AllowOverride option from
All. Save your changes and restart Apache.
sudo /etc/init.d/apache2 restart
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
Image via Fotolia
PHP Authorization with JWT (JSON Web Tokens)
By Miguel Ibarra Romero, Matthew Setter,
Need to authenticate requests to a server? Learn what JWTs are and how to use them instead of sessions to authenticate your users via API calls.
Setting Up a Modern PHP Development Environment with Docker
By Tom Butler,
There are so many ways to set up your PHP development environment, but using Docker is the current best practice. Let's walk through how to do it properly.
Getting Started with Laravel Livewire
By Wern Ancheta,
Vincent is a software developer from Texas working with enterprise applications requiring low-level programming in pure C. Regularly teaching networking and software development, he's a geek and a free software activist.