Gitのリポジトリ更新時にメール通知するスクリプト
hoge.git/hooks/post-update
#!/bin/bash
# リポジトリ更新時にメール送信するスクリプト
# ブランチ名を取得
branch=$(git rev-parse --symbolic --abbrev-ref $1)
# 送信先アドレス
mailaddr="mail@example.com"
# 件名
subject="Gitリポジトリ アップデート通知 (${branch} branch)"
# 本文(最新5コミット)
content=$(git log ${branch} --graph -5)
# メール送信
echo "${content}"|mail -s "${subject}" ${mailaddr}
スクリプトに実行権限を付与するのを忘れずに。
$ chmod +x hooks/post-update