Configuration of cgit

Basic configuration

Before you can start adding repositories you will first have to create the basic cgit configuration file at /etc/cgitrc.

#
# cgit config
#
css=/cgit.css
logo=/cgit.png
# Following lines work with the above Apache config
#css=/cgit-css/cgit.css
#logo=/cgit-css/cgit.png
# Following lines work with the above Lighttpd config
#css=/cgit/cgit.css
#logo=/cgit/cgit.png
# if you do not want that webcrawler (like google) index your site
robots=noindex, nofollow
# if cgit messes up links, use a virtual-root. For example has cgit.example.org/ this value:
virtual-root=/

Adding repositories

Now you can add your repos:

#
# List of repositories.
# This list could be kept in a different file (e.g. '/etc/cgitrepos')
# and included like this:
# include=/etc/cgitrepos
#
repo.url=MyRepo
repo.path=/srv/git/MyRepo.git
repo.desc=This is my git repository
# For a non-bare repository
repo.url=MyOtherRepo
repo.path=/srv/git/MyOtherRepo/.git
repo.desc=That's my other git repository

Or else, it is also possible to configure cgit to automatically search for the repo:

scan-path=/srv/git/

If you use the method above, add the descriptions to .git/description file and add the following lines to show the author:

.git/config

[gitweb]
owner = John Cena <john@riseup.net>

If you are coming from gitweb and want to keep the descriptions and owner information, then use:

enable-git-config=1

For detailed documentation about the available settings in this configuration file, please see the manpage (cgitrc(5)).

Syntax highlighting

Cgit supports syntax highlighting when viewing blobs. To enable syntax highlighting, you have several options.

Using highlight

Copy /usr/lib/cgit/filters/syntax-highlighting.sh to /usr/lib/cgit/filters/syntax-highlighting-edited.sh. Then, in the copied file, comment out version 2 and comment in version 3.
You may want to add --inline-css to the options of highlight for a more colorful output without editing cgit's css file.