SYNOPSYS

gitolite is a wonderfull tool to manage your git repositories.
It’s worth using it even if you only manage your personal repos on your servers.
This setup will prepare the path for cgit (see this post), to see how to deploy it.

PROCEDURE

  • create user and group git
1
root@srv$ useradd -m -U -s /bin/bash git
  • copy admin public key
1
user@host$ scp admin.pub git@srv:.ssh/admin.pub
  • clone gitolite
1
git@srv$ git clone https://github.com/sitaramc/gitolite.git
  • install & configure gitolite
1
2
3
4
5
6
git@srv$ [ ! -d $HOME/bin ] && mkdir $HOME/bin
git@srv$ ln -sf ../gitolite.git/src/gitolite $HOME/bin
git@srv$ $HOME/bin/gitolite setup -pk $HOME/.ssh/admin.pub
git@srv$ sed -i "s/0077/0027/" $HOME/.gitolite.rc
git@srv$ sed -i 's/\(%RC = (\)/\1\n\n LOCAL_CODE => "$ENV{HOME}\/.gitolite\/local-code",\n/' $HOME/.gitolite.rc
git@srv$ sed -i "s/\(GIT_CONFIG_KEYS\s\+=>\s\+'\)/\1gitweb\\\.\.* cgit\\\.\.*/" $HOME/.gitolite.rc
  • UMASK of 0027 gives repo read access to git groups members
  • LOCAL_CODE allows us to keep our hooks and triggers in gitolite-admin.git
  • GIT_CONFIG_KEYS allows us to set cgit.* and gitweb.* repo specific options
  • clone gitolite-admin.git
1
user@host$ git clone git@srv:gitolite-admin
  • add cgit helpers triggers then push

./local-code/triggers/post-compile/update-cgitrc

1
2
3
4
5
6
#!/bin/bash
for repo in $(find ${GL_REPO_BASE} -type d -name "*.git" -prune); do
    [[ "${repo}" =~ "/gitolite-admin\.git$" ]] && continue
    GIT_DIR=${repo} git config --get-regexp 'cgit\..*'
      | awk '{ sub(/ +/, "="); print substr($0, 6); }' > ${repo}/cgitrc
done

.local-code/triggers/post-compile/update-description

1
2
3
4
5
#!/bin/bash
for repo in $(find ${GL_REPO_BASE} -type d -name "*.git" -prune); do
    [[ "${repo}" =~ "/gitolite-admin\.git$" ]] && continue
    GIT_DIR=${repo} git config --get 'gitweb.description' > ${repo}/description
done

  • enable the triggers

/home/git/.gitolite.rc

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
...
# comment out or uncomment as needed
# these will run in sequence after post-update
POST_COMPILE =>
  [
    'post-compile/ssh-authkeys',
    'post-compile/update-git-configs',
    'post-compile/update-gitweb-access-list',
    'post-compile/update-git-daemon-access-list',
    'post-compile/update-cgitrc',
    'post-compile/update-description',
  ],
...

  • now you can create your repos
1
2
3
4
5
6
repo_name "Owner" = "Description"
repo repo_name
R       = @all
RW+     = @devs
config cgit.section = libraries
config cgit.clone-url = git://srv/repo_name.git git@srv:repo_name
  • and check access rights
1
ssh git@srv info repo_name