Another, more modern way to do this is with git-multimail, as suggested by Chords below.
This is how you did it in 2009.
You could add something like this to your post-receive hook in $GITDIR/hooks, or use the script in the contrib directory of the source (Available here)
I managed to do this, but had to opt for using the contrib script, not the other (perl) script by Alexandre Julliard. It seems fancier and more configurable, but with postfix I had no mail command which would accept "-s"? Here's my way:
It would be nice to show some more info, like the full patch, gitweb link and commit graph as well, but this script can only do the first - if I play around with hooks.showrev it seems.
Not exactly a full answer since it is Github-specific, but if you happen to use Github it is extremely easy to configure "Service Hooks".
For each repository you wish to monitor, enter Settings / Service Hooks.
There are plenty of available integrations, such as Trac, Twitter, Amazon SNS, Jira, Asana, Bugzilla, FogBugz, IRC, Jabber, Pivotal Tracker, Trello and Email....
Simply select email and feed it with a group email address.
We use the email notifications to sync our developers.
#!/usr/bin/env ruby
require 'mail'
Mail.defaults do
delivery_method :smtp,
address: 'smtp.gmail.com',
port: 587,
user_name: '...',
password: '...',
authentication: 'plain',
enable_starttls_auto: true
end
changes=`git diff --cached --unified=0 Gemfile Bowerfile`
unless changes.empty?
Mail.deliver do
from '...'
to '...'
subject '[PROJECT] Plese confirm team can use libraries'
body changes
end
end
Install:
cd project
cp pre-commit .git/hooks
chmod +x .git/hooks/pre-commit
gem install mail