Currently, we use gitolite to access control our Git repositories. In addition, we use Redmine to manage our projects.
The standard installation of Redmine can only access a local Git repository via direct access to the file system. Unfortunately, Redmine is not able to show Git repositories via the Git protocol. The latter approach is preferable since gitolite allows access to Git repositories via the Git daemon. By using gitolite as intended, Redmine cannot access bare gitolite-controlled repositories because the Redmine user does not have read permissions on the corresponding directories.
Since Version 1.6 Git provides a clone
option to create a bare repository of an existing one. So the first step to let Redmine show a gitolite-controlled repository is to make a mirror clone of it in a directory that Redmine can access, for instance in /var/git-mirrors
$ git clone --mirror /home/git/repositories/my-repo.git
Since the git
user will keep the two repositories via post-receive
hook in sync, git
needs to have read/write permissions on the mirror clone:
$ cd /var/git-mirrors/
$ chown -R git:git my-repo.git
To keep the repositories in sync, you need to install a post-receive
hook in the gitolite-controlled repositories that mirror-pushes each change to the mirror repository in /var/git-mirrors
:
$ cd /home/git/repositories/my-repo.git/hooks
$ cat >> post-receive << EOF
> #!/bin/sh
> /usr/bin/git push --mirror /var/git-mirrors/my-repo.git
> EOF
$ chown git:git post-receive
$ chmod 700 post-receive
When Git mirror-pushes changes to a repository, it keeps the file/directory permissions from the mirrored repository. Since gitolite maintains the repositories, only the owner of the repository has read and write access. After a mirror-push, the mirror repository cannot by read by anyone else anymore. Therefore, you have to tell the mirror repository that its shared and what file/directory permission it should have:
$ cd /var/git-mirrors/my-repo.git
$ git config --add core.sharedRepository 0644
That’s it. You should be able to integrate the bare mirror repository /var/git-mirrors/my-repo.git
into Redmine and keep it automatically in sync whenever you push to the gitolite-controlled, original repository.