Skip to main content

Redmine git integration with Apache

This is a quick post to explain in a few steps the integration of git scm with redmine.

1- Install git package

On Debian:

# apt-get install git 

2- Create base directory for git repositories

# mkdir /var/git
# cd /var/git

3- Create git repository and initialize

# git init --bare myrepo.git
# cd myrepo.git
# git config http.receivepack true
# git config"your_username"
# git config"username@domain"

4- Finally set correct owner for apache

# chown www-data:www-data /var/git/myrepo.git -R

5- Configure Apache for git repositories

In your redmine virtual host add the following:

    ScriptAliasMatch \
          "(?x)^/git/(.*/(HEAD | \
                        info/refs | \
                        objects/(info/[^/]+ | \
                                 [0-9a-f]{2}/[0-9a-f]{38} | \
                                 pack/pack-[0-9a-f]{40}\.(pack|idx)) | \
                        git-(upload|receive)-pack))$" \

        SetEnv GIT_PROJECT_ROOT /var/git
    <Location /git>
      AuthType Basic
      AuthName "Redmine git repositories"
      Order deny,allow
      Deny from all
      #Allow from server_IP
      Allow from
      Require valid-user
      Satisfy any
      ## for mysql
      RedmineDSN "DBI:mysql:database=redmine;host=db_server"
      RedmineDbUser "dbuser"
      RedmineDbPass "dbpass"
      PerlAccessHandler Apache::Authn::Redmine::access_handler
      PerlAuthenHandler Apache::Authn::Redmine::authen_handler

Go to redmine interface and create a git repository in your project specifying the project path as /var/git/myrepo.git and that’s all!

Leave a Reply

Your email address will not be published. Required fields are marked *


This site uses Akismet to reduce spam. Learn how your comment data is processed.