Git server using gitblit on debian squeeze

Yesterday, one of my friend told me about GitBlit for managing Git repositories, and users, I’ve tried it today, and I really like this product, so I write this post … It will allow me to install a git server using gitblit on debian squeeze.

This post will describe how to set up a git server based on http using GitBlit.

As they said on their web site :

GitBlit is an open-source, pure Java stack for managing, viewing, and serving Git repositories. It’s designed primarily as a tool for small workgroups who want to host centralized repositories.

It’s written as a java web app … We will deploy the war file on a Tomcat Server

Setting up the environment

Install Sun Java 6

first of all we need to install a java platform, i’ve choosed sun’s. Sun java is included in the non-free DEBIAN’s repositories, so we need to activate those repositories …

Edit /etc/apt/sources.list to add non-free to repositories :

deb squeeze main non-free
deb-src squeeze main non-free

After adding non-free repositories update apt list …

apt-get update

Then, add java support :

apt-get install sun-java6-bin sun-java6-jre sun-java6-jdk

Install Tomcat 6

Then we need to install tomcat server :

apt-get install tomcat6 tomcat6-admin

Now, we need to configure access to tomcat manager, Tomcat is installed in /var/lib/tomcat6, webapps will be deployed in /var/lib/tomcat6/webapps, user configuation is located in /var/lib/tomcat6/conf/tomcat-users.xml. Edit this file to add a manager role and an admin user :

<?xml version='1.0' encoding='utf-8'?>
  <role rolename="manager"/>
  <user username="admin" password="YOURPASSWORD" roles="manager"/>

Restart tomcat server :

/etc/init.d/tomcat6 restart

Then you can access to : tomcat manager : http://IP:8080/manager/html and login

Tomcat is installed we will able to deploy some webapps …

gitblit on debian squeeze

Download WAR file

Go to GitBlit and download WAR file

Deploy GitBlit

Go on tomcat’s manager page, and then use WAR file to deploy form to upload GitBlit war file.

NOTE : You may not want to have the GitBlit version number in the context name, for that, simply rename war file : gitblit.war before uploading it to the server

We will create some directories for hosting GIT repositories, and some configuration files :

mkdir /var/git
cd /var/git
mkdir repositories groovy conf

Then you need to configure GitBlit !

On the server edit the file : /var/lib/tomcat6/webapps/gitblit/WEB-INF/web.xml , and change some configuration values :

<!-- ... -->
<!-- ... -->

Then you will need to restart Tomcat :

/etc/init.d/tomcat6 restart

You can now add some Git repositories, go to http://IP:8080/gitblit … login with admin/admin

Problem with "/” in urls

You may have some troubles with "/” URL encoded : %2F. To solve this issue you should add a parameter to Tomcat startup …

Edit the file /etc/default/tomcat6 :

JAVA_OPTS="-Djava.awt.headless=true -Xmx128m -XX:+UseConcMarkSweepGC -Dorg.apache.tomcat.util.buf.UDecoder.ALLOW_ENCODED_SLASH=true"

Setting Up a Proxy

I really don’t like having to set 8080 in url for accessing my installation … So I always add a proxy in front of tomcat, using Apache and mod_proxy

apt-get install apache2
a2enmod proxy_http
/etc/init.d/apache restart

Edit the default vhost file : /etc/apache2/sites-available/default and add those lines in the vhost :

 ProxyPass /gitblit
 ProxyPassReverse /gitblit

And then edit /var/lib/tomcat6/webapps/gitblit/WEB-INF/web.xml , and change some configuration values :


Here you are you can now clone your git repositories …

git clone http://IP/gitblit/git/test.git

Caution !!!

GitBlit Web site say :


  • Gitblit may eat your data. Use at your own risk.
  • Gitblit may have security holes. Patches welcome. 😃


Just a special thanks to Usul !