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.







11 Comments
This worked for me, however, it doesn’t reflect the changes on the recent activities of the project.
Many thanks!
This tip made my redmine access the git repository with gitolite.
Finally I have my project going forward.
I have follwing problem:
My Redmine is only able to access the mirror repo if it has the group www-data. Setting the group to www-data is not possible, because mirroring needs the group git, of course.
How did you solve the problem?
Thanks!
Hey Herb,
Had the same problem as you. I just changed the permissions of the repo to include a+rX (this lets anyone on the system read it). You can do this from the mirrored repo directory by running “chmod a+rX -R ./ -v”
Your website is extremely amazing … keep up the good effort!
Hey thanks for this great article!
I need a little more help, I was hoping you might know whats going wrong.
I followed all the steps and my repository to appear in redmine, but its not all of the files. It only shows files since I started the mirror. For example, if i modify a file ‘main.c’ locally, add and commit to git locally, then push to my gitolite server, at that point it shows up in redmine. Before that it would not. Then if i go and modify another file and do the same, it would show up too. Is there something I am doing wrong with the mirroring? Is this a redmine bug?
could running git version 1.7.2.5 have anything to do with it? i assume not because its still 1.7.x like the continuous integration test builds they already have (git version 1.7.0.4 http://www.redmine.org/projects/redmine/wiki/Continuous_integration).
Fantastic items from you, man. I’ve consider your stuff prior to and you’re simply extremely fantastic. I really like what you’ve bought right here, really like what you are stating and the way in which during which you are saying it. You are making it enjoyable and you continue to care for to keep it sensible. I can not wait to read much more from you. This is actually a great website.