Install Gitolite & Cgit

If you install gitolite as git user:

useradd -m git
su git
cd
mkdir -p bin

git clone git://github.com/sitaramc/gitolite
gitolite/install -ln ~/bin          # please use absolute path here
gitolite setup -pk yourname.pub

If you are using debian, installing cgit is as simple as:

apt-get install cgit

Merge gitolite-admin.git & cgitrc

In this example, we put cgitrc inside gitolite-admin.git so that we can use a single config system to manage both Gitolite and Cgit. We first create a soft link for cgitrc.

rm /etc/cgitrc
ln -s /home/git/.gitolite/local/cgitrc /etc/cgitrc

We then create local/cgitrc in gitolite-admin.git repository.

Show Gitolite Repositories in Cgit

We first config local/cgitrc:

enable-git-config=1
enable-gitweb-owner=1
remove-suffix=1
project-list=/home/git/projects.list
scan-path=/home/git/repositories/

We then set gitweb.description and gitweb.owner for repository:

repo testing
    RW+     =   @all
        R           =   gitweb
    config gitweb.description = For testing purpose.
    config gitweb.owner = Jian Zhou
    config cgit.clone-url = clone-url

Permission

Change the .gitolite.rc file:

21c21
<     UMASK                           =>  0077,
---
>     UMASK                           =>  0027,
24c24
<     GIT_CONFIG_KEYS                 =>  '',
---
>     GIT_CONFIG_KEYS                 =>  '.*',

Convert the existing file permissions:

chmod g+rX repositories

Add git group permission to www-data (for debian):

usermod -aG git www-data

Complete cgitrc

#
# cgit config
# see cgitrc(5) for details

cache-size=1000

css=/cgit-css/cgit.css
logo=/cgit-css/cgit.png

# Show extra links for each repository on the index page
enable-index-links=1

# Enable ASCII art commit history graph on the log pages
enable-commit-graph=1

# Show number of affected files per commit on the log pages
enable-log-filecount=1

# Show number of added/removed lines per commit on the log pages
enable-log-linecount=1

# show number of tags
summary-tags=10

# Enable statistics per week, month and quarter
max-stats=week

# Set the title and heading of the repository index page
root-title=@janzhou Git Central

# Set a subheading for the repository index page
root-desc=Jian Zhou Personal Git Source

# Allow download of tar.gz, tar.bz2 and zip-files
#snapshots=tar.gz tar.bz2 zip
snapshots=tar.gz zip

##
## List of common mimetypes
##

mimetype.gif=image/gif
mimetype.html=text/html
mimetype.jpg=image/jpeg
mimetype.jpeg=image/jpeg
mimetype.pdf=application/pdf
mimetype.png=image/png
mimetype.svg=image/svg+xml

# Show owner on index page
enable-index-owner=1

# Enable syntax highlighting (requires the highlight package)
# source-filter=/usr/lib/cgit/filters/syntax-highlighting.sh

# through the right converters
about-filter=/usr/lib/cgit/filters/about-formatting.sh

readme=:README.md
readme=:readme.md
readme=:README.mkd
readme=:readme.mkd
readme=:README.rst
readme=:readme.rst
readme=:README.html
readme=:readme.html
readme=:README.htm
readme=:readme.htm
readme=:README.txt
readme=:readme.txt
readme=:README
readme=:readme
readme=:INSTALL.md
readme=:install.md
readme=:INSTALL.mkd
readme=:install.mkd
readme=:INSTALL.mkd
readme=:install.mkd
readme=:INSTALL.rst
readme=:install.rst
readme=:INSTALL.html
readme=:install.html
readme=:INSTALL.htm
readme=:install.htm
readme=:INSTALL.txt
readme=:install.txt
readme=:INSTALL
readme=:install

##
## List of repositories.
## PS: Any repositories listed when section is unset will not be
##     displayed under a section heading
## PPS: This list could be kept in a different file (e.g. '/etc/cgitrepos')
##      and included like this:
##        include=/etc/cgitrepos
##

enable-git-config=1
enable-gitweb-owner=1
remove-suffix=1
project-list=/home/git/projects.list
scan-path=/home/git/repositories/

# repo.url=testing
# repo.path=/home/git/repositories/testing.git
# repo.desc=This is a testing repository.
# repo.owner=Jian Zhou

Reference