Adding a gitolite-controlled repository to Redmine

本文介绍如何通过创建镜像仓库的方式将受Gitolite控制的Git仓库集成到Redmine中,保持两者同步更新,并确保Redmine可以正确显示Gitolite管理的仓库。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

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.

 

原文转自:http://ambitz.com/2011/03/07/adding-a-gitolite-controlled-repository-to-redmine/

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值