Rss Feed Tweeter button Facebook button Technorati button Reddit button Linkedin button Webonews button Delicious button Digg button Flickr button Stumbleupon button Newsvine button

A Waage Blog

Ruby, Rails, Life

Archive for the ‘notifications’ tag

Adding Git Email Notifications via Post-receive hook

with 8 comments

This was done on Fedora 10 in my case, but should be similar for all distributions. This is set up on a shared ‘central’ repository, where changes are pushed to. That’s why it’s done using the post-receive hook (the repository receives changes).

Step 1: Copy (or symlink) the post-receive script, or download it here. The script must be in the ‘hooks’ directory like this:

I’ve read that on Debian systems, for example, the hook is stored in /usr/share/doc/git-core/contrib/hooks/post-receive-email but i had no luck finding it here on my system.

Make sure it is named “post-receive” so that Git recognizes it.

Step 2: Make sure that the script is executable:

chmod a+x $GIT_DIR/hooks/post-receive

Step 3: Edit the first line of $GIT_DIR/description to be your repository name. This will be in the subject of the email.

Step 4: Edit $GIT_DIR/config with some email settings such as recipient / sender email and subject-line prefix. Here’s some basic settings (read the script for all possible settings).

mailinglist = ","
envelopesender =
emailprefix = "[GIT] "

Note: you can also set these by using git-config:

git-config hooks.mailinglist ","
git-config hooks.envelopesender
git-config hooks.emailprefix "[GIT] "

That’s it ! Try doing a git-push to your shared repository, and see if you get email notifications. If not, try tailing your mail log to see what’s wrong (/var/log/maillog).

Written by Andrew Waage

May 19th, 2010 at 1:39 pm

Posted in Git and SVN

Tagged with , , , ,