Git Commit eMail Notifications

Git’s Native eMail Notifier

From the repository you wish to send email on commits.

cd .git/hooks
mv post-receive post-receive.bkp
ln -s /usr/share/git-core/contrib/hooks/post-receive-email post-receive git config hooks.mailinglist ""
git config hooks.emailprefix "[SUBJECT PREFIX] " # note the trailing space 

Git Commit Notifier

This ‘plugin’ will allow you to send an email every time a commit is committed to the repository. You may use this on the central repository to keep everyone following the project up to date.

To use this plugin, you first need to compile the script, then add the config information to each repository you wish to use it on.

To Install Git Commit Notifier

On Fedora 12 you first need to install Ruby and a few other dependences. After you download the needed dependences, you may compile the script.

yum install ruby rubygems hpricot rubygem-hpricott
gem install git-commit-notifier

To Configure Git Commit Notifier

In your repository’s .git/hooks folder or if it’s a “bare” repository, just the hooks folder. Create a file named
post-receive with the following content.

git-commit-notifier ../git-commit-notifier.yml

Once you have saved the file, you need to make it executable.

chmod 775 post-receive

After you have made the hook executable, check up one directory to the repository’s .git directory. From here you need to create and modify your git-commit-notifier’s config file. Start out by creating a file named git-commit-notifier.yml, and copy the below config to it.

Git Commit Notifier Config File

# The recipient for the commit:

# set to true if you want to ignore empty merge messages
ignore_merge: false

# Optional parameter for the subject-line of the mail
# emailprefix: GIT

# Decorate files with link to a webview. Possible values: none or gitweb link_files: none

# select the delivery method: smtp or sendmail
delivery_method: sendmail

# settings for the smtp server
address: localhost
port: 25
domain: localhost
user_name: user@localhost
password: password
authentication: plain
enable_tls: false

# settings for sendmail
location: /usr/sbin/sendmail
arguments: -i -t

# If link_files is set to "gitweb", you need to configure the path to your gitweb
# instance and the project name.
path: <a href="http://developerserver/path_to_gitweb">http://developerserver/path_to_gitweb</a>
project: test.git

5 thoughts on “Git Commit eMail Notifications

  1. 1. I had to do ‘git config hooks.emailprefix PFX’ and ‘git config hooks.mailinglist‘ to make it ‘work’ (see 2.)

    2. I get the following error:

    remote: /usr/lib/ruby/gems/1.8/gems/git-commit-notifier-0.10.5/lib/git_commit_notifier/emailer.rb:141:in `send': undefined method `to_sym' for nil:NilClass (NoMethod Error)

    Any hints ??

  2. I installed git-commit-notifier but each time I pushed i get the error, hooks/post-receive: 15: git-commit-notifier: not found. When i ran gem –list local, it showed that git-commit-notifier was installed. Where is the excutable installed?

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s