Configuring a Git repository with Redmine

One of the features I enjoy the most about Redmine is the built-in support for the most common SCM tools including Subversion, Git and Mercurial. As a Rubyist, you are probably using Git for the most of your Ruby/Rails projects and chances are you'd like to have Redmine synchronized with your Git repositories.

Configuring a Git repository with Redmine it's really straightforward but if you come from the Subversion world, there are a couple of things you need to know to better understand how Redmine interacts with remote repositories.

Repository Settings

First step is to configure the repository settings in Redmine. Open your project page, then go to Settings > Repository.

Choose the Git option, then you'll be asked to enter the path to the Git repository. The path to the repository is the absolute path to the .git folder that represents the repository and contains all the files .git uses to manage your project history.

Due to the way how Git works, this path must point to a folder on your local server. Unlike Subversion, you can't type the address to a remote repository.

Let me show you an example. Assuming I want to configure my helperful GEM repository, I first need to clone the repository on my server then type the absolute filesystem path, for instance

/home/weppos/git/helperful/.git

Using the remote clone URL won't work because Git can't send status commands over the network to remote repository. You can only push to or pull from remote repositories but you need a local clone to work on. This is how Git works.

Again, don't try to fill the field with one of the following addresses:

Hit the create button and go to the Repository page. If your configuration is correct, the page should display the most recent repository commits.

Fetching new commits

If you have used Redmine with Subversion before, you probably noticed that Redmine automatically fetches the latest commits each time you visit the Repository section.

Basically, when you open the Repository page, Redmine contacts the remote SVN repository and asks for the latest revision number. Then, it compares the value with the last changeset in the database and, if new commits are available, it fetches and parses them on-the-fly.

Again, Git is not a centralized repository and Redmine doesn't support remote Git repositories. This means, you need to setup a separate process to update your local Git repository and notify Redmine of new commits.

The most simple way to achieve this goal is configuring a crontab on your server.