Patch #2173


Update the Git repository automatically

Added by David Holm over 15 years ago. Updated about 11 years ago.

Needs feedback
SCM extra
Target version:
Start date:
Due date:
2013-04-01 (over 11 years late)
% Done:


Estimated time:


The Wiki suggests ( that you should set up a cron job to update the Git bare repository, the one redmine points to, automatically. This is unneccessary since you could just as easily use Git's hooking mechanism to have it automatically update the repo on each push.

1. chmod a+x post-receive-redmine
2. Put post-receive-redmine in <redmine dir>/doc/git-hooks
3. Change into your main git repo dir (the one you push to)
4. Edit ./hooks/post-receive and add a line that says ". <redmine dir>/doc/git-hooks/post-receive-redmine"
5. Run "git config --add hooks.redmineGitBase <base path to redmine bare repos, i.e. /var/lib/redmine/git_repos>"
6. You're done!

The script could be updated to create the bare repo if it doesn't already exist but it would need to know which permissions to change it to for redmine to read it so I didn't add this feature.


post-receive-redmine (387 Bytes) post-receive-redmine post-receive-redmine David Holm, 2008-11-13 09:03
post-receive-redmine (383 Bytes) post-receive-redmine post-receive-redmine David Holm, 2008-11-13 11:19
post-receive-redmine_v2 (416 Bytes) post-receive-redmine_v2 Radomir Mladenovic, 2009-03-25 19:33
post-receive-redmine_v3 (1.63 KB) post-receive-redmine_v3 L Philbrook, 2010-02-04 02:26
post-receive-redmine_v3 (1.87 KB) post-receive-redmine_v3 L Philbrook, 2010-02-04 03:25

Related issues

Related to Redmine - Feature #1454: Support repository syncing for new repository importsNew2008-06-15

Actions #1

Updated by David Holm over 15 years ago

Note that the post-receive-redmine script is executed with the permissions of the commiter so that person has to have write access to the redmine bare repo in order for the git push to succeed.

I have an "rnd" group where everyone in R&D belongs so I did:
setfacl -d -m g:rnd:rwx /var/lib/redmine/git_repos

Actions #2

Updated by David Holm over 15 years ago

Updated script, uses $PWD rather than $GIT_DIR to figure out the repo dir since GIT_DIR might very well be '.'.

Actions #3

Updated by Radomir Mladenovic about 15 years ago

Thanks for the script! It's exactly what I needed. I still don't understand why push works but fetch called from the redmine repo doesn't (at it looks as a natural thing to do) but... I'm quite fresh with git.

In my case main git repo dir has a suffix ".git" (e.g. /var/git/repositories/internal/test.git) but redmine bare clone not (e.g. /var/git/checkout/internal/test) so I made a small modification to your script to remove the suffix. (It's attached.)

Also, it wasn't clear to me from your post that "hooks.redmineGitBase" should point to the parent of redmine repos directory (e.g. /var/git/checkout/internal in my case). If multiple repositories have the same base (as they probably do) it may be worth to set this property on a global level.

Actions #4

Updated by L Philbrook over 14 years ago

I added bare repo creation via ssh or file and the ability to set a global redmineGitBase from within the script. I also added some additional validation. This is against Radomir v2, so .git is removed in the cloned repo.

Actions #5

Updated by L Philbrook over 14 years ago

Found a couple of errors in my last submission. Added even more error checks and a call to modify the hooks directory to remove execution.

Actions #6

Updated by Toshi MARUYAMA about 13 years ago

  • Category changed from SCM to SCM extra
Actions #7

Updated by Anonymous over 11 years ago

I think this all is not necessary anymore thanks to the WS API keys, see the Redmine User's guide and also this HowTo

However, what should be fixed is the plethora of different guides for repository access which mention different methods, but don't mention the WS API key. It is very difficult to navigate this jungle and find the "correct" information... Perhaps a single "official" guide should be created, and all the other guides should be augmented with a header pointing to the official guide, and stating that these other guides may work, but may also be updated, and should be used with caution...

Actions #8

Updated by Daniel Felix over 11 years ago

  • Due date set to 2013-04-01
  • Status changed from New to Needs feedback

Well I'm not sure if this one could be really closed. This is another approach to update the repo.

I would tend to close this issue too, but I would like to give the community the chance to give feedback on this.
I set this issue to needs feedback and will close it on 1th April if there is no feedback which tends to the other side.

For your purpose of a global handbook,... This sounds like a good idea. I'm not sure how we should do this, but maybe I get a good concept the next days. :-)

Actions #9

Updated by Daniel Felix about 11 years ago


any news on this? I'm not really sure if this one should be closed or not.

Best regards,


Also available in: Atom PDF