Patch #2173

Update the Git repository automatically

Added by David Holm about 14 years ago. Updated almost 10 years ago.

Status:Needs feedbackStart date:2008-11-13
Priority:NormalDue date:2013-04-01
Assignee:-% Done:


Category:SCM extra
Target version:-


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 - post-receive-redmine (387 Bytes) David Holm, 2008-11-13 09:03

post-receive-redmine - post-receive-redmine (383 Bytes) David Holm, 2008-11-13 11:19

post-receive-redmine_v2 (416 Bytes) Radomir Mladenovic, 2009-03-25 19:33

post-receive-redmine_v3 (1.63 KB) L Philbrook, 2010-02-04 02:26

post-receive-redmine_v3 (1.87 KB) L Philbrook, 2010-02-04 03:25

Related issues

Related to Redmine - Feature #1454: Support repository syncing for new repository imports New 2008-06-15


#1 Updated by David Holm about 14 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

#2 Updated by David Holm about 14 years ago

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

#3 Updated by Radomir Mladenovic almost 14 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.

#4 Updated by L Philbrook about 13 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.

#5 Updated by L Philbrook about 13 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.

#6 Updated by Toshi MARUYAMA almost 12 years ago

  • Category changed from SCM to SCM extra

#7 Updated by Anonymous almost 10 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...

#8 Updated by Daniel Felix almost 10 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. :-)

#9 Updated by Daniel Felix almost 10 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