How to install Gitiles – repository browser for Git repositories on Ubuntu Linux

Gitiles is a simple repository browser for Git repositories, built on JGit. Its guiding principle is simplicity: it has no formal access controls, no write access, no fancy Javascript, etc.

Gitiles automatically renders *.md Markdown files into HTML for simplified documentation.

Gitiles requires Bazel to build. You need to use Java for building Gitiles. Below steps installs Bazel and JDK as,

$ sudo apt install maven
$ sudo apt-get install openjdk-8-jdk
$ echo "deb [arch=amd64] http://storage.googleapis.com/bazel-apt stable jdk1.8" | sudo tee /etc/apt/sources.list.d/bazel.list
$ curl https://bazel.build/bazel-release.pub.gpg | sudo apt-key add -
$ sudo apt-get update
$ sudo apt-get install bazel
$ sudo apt-get upgrade bazel

Make sure you are using openjdk-8-jdk

$ update-java-alternatives --list
$ sudo update-java-alternatives -s java-1.8.0-openjdk-amd64

Build and Install gitiles

$ mkdir /home/devlab/git_server
$ cd /home/devlab/git_server
$ git clone https://gerrit.googlesource.com/gitiles
$ cd gitiles
$ bazel build //...
$ bazel test //...

Here, for demo, we have created directory as “/home/devlab/git_server” you can create any directory and use the same to download the gitiles source code.

Create git repos which we want to display using gitiles on browser

The last step of setting up gitiles is to make sure, we start the gitiles server from the git repositories directory, as for understanding we will use two git repositories, 1. Existing downloaded git 2. Bare git repository we created

Setup for using Existing downloaded git

$ cd /home/devlab/git_server 
$ mkdir git_repos 
$ cd git_repos 
$ git clone https://github.com/lynxbee/netdata.git 

Now we have already existing git repository, which we just downloaded from github using git clone command, now the last important step is to start the gitiles server, the source code of which we downloaded and compiled using bazel as shown above and is in “/home/devlab/git_server/gitiles”

Now we need to start the gitiles server from the same location where we have the git repositories,

$ cd /home/devlab/git_server/git_repos
$ bash /home/devlab/git_server/gitiles/tools/run_dev.sh 

This will start the gitiles server and we can explore the git repositories over browser at http://localhost:8080/

Setup for using bare git repositories

Steps to setup the gitiles server remains same as above, except instead of “git clone”, we create the bare git repository locally which any one can use to push the code..

$ cd /home/devlab/git_server/git_repos
$ mkdir bare_git_example 
$ cd bare_git_example 
$ git --bare init 
$ cd .. 
$ bash /home/devlab/git_server/gitiles/tools/run_dev.sh 

This will start the gitiles server and we can explore the git repositories over browser at http://localhost:8080/

Reference : https://github.com/google/gitiles

Leave a Comment