How to get email diffs for GitHub pushes?

Has anyone come up with a good way to get emails when commits are pushed to your GitHub repo -- that includes a diff of files changed?

(I know they have an Email Service Hook - but that doesn't include a diff)

Mega bonus points if the diffs are colorized with inline CSS that's viewable in Gmail.


I've written a small WebHook that exactly fills this gap: gitdub. It leverages git-notifier to send one email per commit.

You are right, the GitHub Email Service hook doesn't include diff: this is currently a feature request.

J-16 SDIZ is also right, git-hook-update-notify-email would only be executed locally, not on GitHub side.

That doesn't mean said script cannot help: the idea would be to

  • setup a bare repo on your side, cloning the GitHub repo
  • setup a clone of that base repo
  • have a cron job (or Windows task) fetching the GitHub repo every 10 minutes
  • immediately push to the local non-bare repo

In the local non-bare repo, you can:

  • either use a pre-receive hook (which, as described in the Git book, could be use to compute diff between old-rev and new-rev)
  • or use the aforementioned git-hook-update-notify-email

In both cases, that mean setup this kind of service locally, which is not ideal.

May not be the ideal answer for you but if you set up gitolite on your own server you can setup git-commit-notifer, get beautiful colored diff emails, and have unlimited git accounts since you own the server. I do this, and I have never looked back.

Don't have a server? You can get a micro Amazon EC2 instance for dirt cheap ($15 a month). We have up to 12 developers and 10 git repos and it all works great on a micro instance.

The way of doing this is by adding a notification hook script which posts data to your system, with each commit that has been pushed to github.

E.g.: the payload consists of each commits applied, each having an id:

  :before     => before,

  :after      => after,

  :ref        => ref,

  :commits    => [{

    :id        =>, <--- here

Second step is to make your script trigger a call to github, using github API, that fetches each commit included in the payload. The response includes a diff for each file, which then you can email to your developers.


GET /repos/:owner/:repo/commits/:sha

:sha is the id of the commit you are getting the code for, and the response looks like this:


 "files": [

      "filename": "file1.txt",
      "additions": 10,
      "deletions": 2,
      "changes": 12,
      "status": "modified",
      "raw_url": "",
      "blob_url": "",
      "patch": "@@ -29,7 +29,7 @@\n....." <---- HERE

Hope this helps. Please ask if you need more details about how to do it.

Need Your Help

xperf WinDBG C# .NET 4.5.2 Application - Understanding process dump

c# .net windbg jit xperf

Under a heavy load, our application is making a beefy server go to 100% CPU usage. Reading the process dump, looking at the threads, some of them are 10 minutes up. None of them give me any insight...

How to use C++ std::ostream with printf-like formatting?

c++ formatting printf ostream

I am learning C++. cout is an instance of std::ostream class.