RedmineRepositories » History » Revision 25
« Previous |
| Next »
Benoit Bénézech, 2009-11-02 16:38
git fetch needs a git reset needed to rebuild the tree
- Table of contents
Redmine natively supports integration with different SCM-tools: Subversion, CVS, Mercurial, Darcs, Git, and Bazaar.
Note that you need to install the appropriate binaries on your Redmine host and make sure that these binaries are available in the
PATH environment variable:
|Subversion||1.3 & 1.4 & 1.5 & 1.6||1.3 or higher required|
|CVS||1.12.12||1.12 required, won't work with CVSNT|
For example, if you want to access Subversion repositories in Redmine, you'll have to install the svn binaries on the Redmine host. Redmine currently doesn't make use of the Ruby Bindings for Subversion.
Attaching an existing repository to a project¶
In the project settings, make sure that the 'Repository' module is enabled and go to the 'Repository' tab.
Select the SCM that corresponds to your repository and enter the path or URL of your repository.
Important: When you first browse the repository, Redmine retrieves the description of all of the existing commits and stores them in the database.
This is done only once per repository but can very long (or even time out) if your repository has hundreds of commits.
To avoid this, you can do it offline.
After having your repository declared in Redmine, run the following command:
$ ruby script/runner "Repository.fetch_changesets" -e production
All commits will be retrieved in the Redmine database.
The usual protocols are supported (eg.
file:), just enter the URL of the repository.
You can specify a username and password if the repository requires authentication.
Note: if you want to access the repository using
svn+ssh://, you'll have to configure svn+ssh to be non-interactive.
This requires to setup a public/private key pair for ssh authentication.
- the URL of the repository (it can be either a path or a connection string, eg.
- the module name
Local environment setup¶
Redmine requires a bare and local repository to enable browsing through Redmine.
Imagine you want to browse the to-do list manager project "Donebox": its clone URL is
On the server where you're running Redmine, create a directory accessible by the user running your Redmine server:
$ sudo mkdir -p /var/redmine/git_repositories $ sudo chown rails:rails /var/redmine/git_repositories $ cd /var/redmine/git_repositories
Note the second line: it changes the ownership of the newly created directory to the user
rails and the group
rails. Of course, you have to replace it according to your server settings (it can be
apache or when you are having a very bad sysadmin:
root). Keep in mind that this user needs to have the (local-)permissions to run the
Create the bare repository¶
After the preceding steps have been taken it is time to create our bare repository:
$ pwd /var/redmine/git_repositories $ git clone --bare git://github.com/ook/donebox.git Initialized empty Git repository in /var/redmine/git_repositories/donebox/ remote: Counting objects: 401, done. remote: Compressing objects: 100% (246/246), done. remote: Total 401 (delta 134), reused 401 (delta 134) Receiving objects: 100% (401/401), 179.55 KiB | 185 KiB/s, done. Resolving deltas: 100% (134/134), done.
Our bare repository is now created successfully! Now go to your Redmine project settings, go to the repositories tab and choose
git as the SCM, then put in the "Path to .git directory" (in our example this is
/var/redmine/git_repositories/donebox/) and save the settings. Have a look at your repository tab: you should now be able to browse your repository successfully.
Note: of course, this git repository won't update by itself. You'll have to
git pull it regulary by hand, set up a cron job which will execute the
git pull-command automatically for you or use a post-receive hook, like this one :
echo "Post receive-hook => updating Redmine repository" sudo -u my_redmine_user -p secret perl -we '`cd /redmine/repositories/my_repo.git && git fetch && git reset refs/remotes/origin/master`'
Note the git reset, you'll need it to update the git tree and see your changes in the Repository view.
Bare repository on Windows¶
If your bare repository is install on Windows, adding :
;%GIT_PATH%\cmd;%GIT_PATH%\bin;to your %PATH% environment variable.
Where %GIT_PATH% is the install directory of Git (eg: C:/Git)
To synchronize with a Mercurial repository, you will have to have a local clone of the repository on the same server you have Redmine installed on. Let's say you put Redmine in /var/www/redmine.example.com/www and have put your mercurial repository in /var/www/sources.example.com/repo/example, you would have to select Mercurial as a SCM, then enter /var/www/sources.example.com/repo/example in the repository text box.
This will start checking out the Mercurial repository, and you won't see the results straight away. Wait for a few seconds (or possibly minutes), and click the Repository tab of your project (not of your configuration settings). You should now see the results appear.
Updated by Benoit Bénézech over 13 years ago · 25 revisions