Gitblit - a simple Git Repository Manager

Categories: Programming, BigData


This page describes the gitblit Git repository manager, and how to install it on Linux.

Gitblit provides:

  • a server that understands the Git remote network protocols, ie supports pull/push from remote systems (with authentication) via http://, ssh:// and git:// urls
  • a web interface that allows git repos to be defined, users and credentials to be managed, and code to be browsed.

Gitblit is much simpler than alternatives like Github/Gitlab/Bitbucket - but far less resource-hungry. It is also very simple to install.

The Github project page for gitblit is rather inactive (and I could not find any active forks) - but Gitblit just works.

There are two bundles offered by the project: a Java war-file intended to be run within a Java Servlet Engine, and the “Gitblit GO” bundle that embeds a servlet engine. Given that the downloads are so old (inactive project), I would recommend using the war-file with an up-to-date servlet engine, and that is the approach documented below.



Install Java - eg on Ubuntu apt install openjdk-8-jre-headless.

Note that gitblit has problems with Java 9 and later:

  • the launcher for “Gitblit GO” requires access to URLClassLoader, but this is class is inaccessible in Java 9 and later
  • the war-file requires various libraries (including javax.activation) which are not included in Java 9; this is potentially fixable by adding the necessary libraries into Tomcat’s lib directory but using openjdk-8 seems a simpler solution (at least as long as Java 8 is supported).

Other Tools

Ensure that Git is installed, eg on Ubuntu apt install git.

Installing Tomcat

Install the Apache Tomcat Java Servlet Engine. Ubuntu has a standard package for this (apt install tomcat8) but this creates a user tomcat8 and automatically starts Tomcat on the standard ports as that user; ideally gitblit would be run as its own user. I therefore recommend installing Tomcat manually as follows.

To install Tomcat 9 manually into /opt, run the following instructions as root:

cd /tmp
wget http://.../apache-tomcat-9.*.tar.gz  # obtain actual link to current release from
tar zxf apache-tomcat*
rm apache-tomcat-9*.tar.gz
mv apache-tomcat-9* /opt
cd /opt
ln -s apache-tomcat-9* tomcat9
cd tomcat9
find . -type d -exec chmod o+x {} \;
chmod -R o+r . 
chmod o+x bin/*.sh

The instructions below take advantage of Tomcat’s ability to store the core binaries in a central location, and have each “tomcat instance” just consist of the necessary config-files and directories while referencing the core binaries from the central location. In particular, script “bin/” makes this easy - but that is only included in Tomcat 9 and later. Gitblit works fine with Tomcat 9.

Install Gitblit Files

First, (as root) create a user for gitblit to run as:

mkdir /opt/gitblit
useradd --system --home /opt/gitblit --shell /usr/sbin/nologin gitblit
chown -R gitblit:gitblit /opt/gitblit

Then as the gitblit user (su --shell /bin/bash gitblit):

  • Download the gitblit warfile from the gitblit home site, eg to /tmp/gitblit.war (wget is the recommended tool)
  • Run the following instructions
cd ~
sh /opt/tomcat9/bin/ tomcat

# Optionally edit ~/tomcat/conf/server.xml to change the default ports

# Install gitblit into tomcat
mv /tmp/gitblit.war ~/tomcat/webapps/gitblit.war

# Unzip manually so that files can be edited
cd ~/tomcat/webapps/
unzip gitblit.war

# Optionally, configure gitblit
# By default, {basefolder} is WEB-INF/data, ie git repos are stored under WEB-INF/data/git
edit gitblit/WEB-INF/data/ 


The gitblit application:

  • opens a port for git:// access to the repos (defined in WEB-INF/data/ as 9418; can be overridden in WEB-INF/data/
  • opens a port for ssh:// access to the repos (defined in WEB-INF/data/ as 29418; can be overridden in WEB-INF/data/
  • and of course uses the tomcat ports specified in conf/server.xml
    • 8080 for http
    • 8443 for https
    • 8005 for startup/shutdown - localhost interface only
    • 8009 for AJP1.3 protocol (when a webserver such as Apache HTTPD is forwarding requests to Tomcat) - localhost interface only

Set up systemd-init

As root, set up systemd as follows:

cat > /etc/systemd/system/gitblit.service <<EOF


Environment='CATALINA_OPTS=-Xms512M -Xmx1024M -server -XX:+UseParallelGC -Dorg.apache.tomcat.util.buf.UDecoder.ALLOW_ENCODED_SLASH=true'
ExecStart=/bin/sh /opt/tomcat9/bin/ run

systemctl daemon-reload
systemctl enable --now gitblit
systemctl status gitblit
journalctl --unit=gitblit --since="- 5 minutes"

Use Gitblit

Now you can visit the app at http://{yourhost}:8080/gitblit/. The default login credentials are admin/admin.

Within the web UI, you can:

  • create new repositories (which creates a git repo on local filesystem)
  • add users and grant them access to repos