How do I configure the appropriate Git hook to send a summary email whenever a set of changes is pushed to the upstream repository?
11 Answers
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)
-
If I reference that script in my hooks, does the referenced script have to reside on the upstream host or locally? – Head Feb 16 '09 at 06:50
-
4The host that is executing the hook, so in the case of a post-receive, the upstream host (whereas a post-commit hook would need the script on the host you're running the commit on). – mwalling Feb 16 '09 at 07:16
-
2Ahhh, but you can accept the answer and you'll both get more reputation! – Pat Notz Feb 16 '09 at 14:09
-
The part that got me was setting the recipients list. I finally figured it out that you need to use git config: git config hooks.mailinglist "person1@example.com, person2@example.com" – ewalk Jul 20 '11 at 22:19
-
4It's worth noting that the link in this answer is no longer under active development. Instead, use [multimail](http://git.kernel.org/cgit/git/git.git/tree/contrib/hooks/multimail/README?id=HEAD), which is mentioned in the readme. – Chords Oct 30 '13 at 20:07
-
@Chords Does "no longer under active development" mean that it cannot be used anymore? – Яois Jul 23 '14 at 14:03
Here is the simplest solution I've found:
1) Log in to your gitHub account on github.com
2) In the main tab click on Settings
3) From the main navigation choose Service Hooks
4) From Available Hooks choose Email
5) Fill in your email address in field Address
6) Check the checkbox Send from Author
7) Check the checkbox Active
8) Click on Update Settings
Optional: You can click on Test Hook for testing, check your inbox you should receive email.
Also there are images made according to the process:
And now for the grand final I have the answer which is tested and approved at my side.
How to send email to ALL development team members, when gitHub's Service Hooks->Email allows only at most 2 recipients }.
The answer is combination of Service Hook->Email @ GitHub && Google groups
- First login to your google account
- Go to Google Groups and at the top click on Create Group
- Type in Group Name, Group email address (will copy/paste into GitHub Service Hook->Email Address), Group description
- After that hit Create button at the top, your new group should be created now
- After that in the menu to the left hit Invite members and type in the email addresses of your team mates
- After that hit Send invites (when your members accept invitation) they are now formally members of this group
- In the menu on the left click on All Members and check the 4th column called Delivery, every team member should have option All Email.
- After that I would like to credit Mr. Clement Escoffier and please do follow his guidelines @ Clement Escoffier::Send Github commits to a Google Group on how to finish it. {Thank you Clement :)}
- If the link becomes unavailable here is another link to my gDocs @ PDF version of Clements guide

- 17,604
- 2
- 48
- 43
-
21This is a github solution. Nothing in the question tells me that the user are using github. Looks like it is a perfect answer for a question on github though. – daramarak Nov 10 '14 at 09:12
-
4This email service is going to discontinued after Oct 2018. So this answer is not valid after that point. https://developer.github.com/changes/2018-04-25-github-services-deprecation/ – Jeegar Patel Jul 11 '18 at 09:57
This is my way of send email notification to users every time some one push to the repository.
Setting Up Git Commit Email Notification
It's based on Andy Parkins's scripts. I change it to used SMTP to send email. Of course, gmail's SMTP can also be used.

- 599
- 1
- 4
- 17

- 101
- 1
- 2
Robin Sommer's git-notifier generates also very nice summaries in the following format:
Subject: [git/git-notifier] master: Adding www target to Makefile. (7dc1f95)
Repository : ssh://<removed>/git-notifier
On branch : master
>---------------------------------------------------------------
commit 7dc1f95c97275618d5bde1aaf6760cd7ff6a6ef7
Author: Robin Sommer <robin@icir.org>
Date: Sun Dec 19 20:21:38 2010 -0800
Adding www target to Makefile.
>---------------------------------------------------------------
Makefile | 6 ++++++
1 files changed, 6 insertions(+), 0 deletions(-)
diff --git a/Makefile b/Makefile
index e184c66..9c9951b 100644
--- a/Makefile
+++ b/Makefile
@@ -5,6 +5,8 @@ VERSION = 0.1
DISTFILES = git-notifier README COPYING
+WWW = $(HOME)/www/git-notifier
+
all:
dist:
@@ -13,3 +15,7 @@ dist:
cp $(DISTFILES) git-notifier-$(VERSION)
tar czvf git-notifier-$(VERSION).tgz git-notifier-$(VERSION)
rm -rf git-notifier-$(VERSION)
+
+www: dist
+ rst2html.py README >$(WWW)/index.html
+ cp git-notifier-$(VERSION).tgz $(WWW)

- 12,242
- 10
- 53
- 87
setting hooks.showrev is making no distinguishable difference? :-/
Sample conf:
# less users/cj.git/config
[core]
repositoryformatversion = 0
filemode = true
bare = true
[hooks]
mailinglist = cj@yoga.ee
showrev = "git show -C %s; echo"
emailprefix = "[sabu gitosis server] "

- 3,406
- 3
- 17
- 11
-
Ah, turns out the git.kernel.org version respected hooks.showrev, but default git installation script didn't! Just replaced the script, chmod a+x and then it works! Still need to understand the showrev syntax though – HiQ CJ Nov 24 '09 at 10:27
-
Similar issues with showing diffs here: http://stackoverflow.com/questions/804601/git-post-receive-email-hook-including-diff-patches/1790161#1790161 – HiQ CJ Nov 24 '09 at 13:48
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:
http://pastie.textmate.org/695323
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.
Anyway, cheers and thanks for the suggestions!

- 3,406
- 3
- 17
- 11
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.

- 8,889
- 8
- 54
- 62
If you use GitLab you can use the 'Email-on-push' project service for this, it can be found under services in project settings.

- 1,885
- 2
- 22
- 20
You can use pre-commit:
#!/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
Test:
echo "# some change" >> Gemfile && git commit -m 'some change' Gemfile

- 8,247
- 4
- 44
- 37
In GitLab under your repository:
- Click on Setting.
- When setting expands there you will see Integrations. Click on it.
There opens a new page Emails on push
- Locate and select Send from committer.
- Also, enter the Recipients with comma separated located at the last field.
Also there is an option for Disable code diffs which exclude possibly sensitive code diffs in notification body. It is optional.
For more details: Click Here

- 2,136
- 2
- 12
- 26