- State project name for Git by altering first row of $GIT_DIR/description
- Inform Git about the mail configuration by appending in $GIT_DIR/config
[hooks]
mailinglist = email1@example.com email2@example.com
senderemail = myemail@example.com
- Create a notification script in $GIT_DIR/hooks/post-commit.sample
Example:
#!/bin/sh
#
# An example hook script that is called after a successful
# commit is made.
#
# To enable this hook, rename this file to "post-commit".
projectdesc=`sed -ne '1p' "$GIT_DIR/description"`
recipients=`git config hooks.mailinglist`
full_commit_log=`git log -p -1 HEAD`
commit_msg=`(git log -1 HEAD |
egrep -v '^commit|^Author|^Date')`
(
id -P |
gawk -F: '{
print $1 " (" gensub(",.*", "", "", $8) ") committed:"
}
END {
print "\nRepository: '"$2"'\n"
}'
echo "Branch of commit is: `git branch`\n"
echo "$full_commit_log"
) | mail -s "[$projectdesc] git commit '$commit_msg'" $recipients
- Rename post-commit.sample to post-commit
mv post-commit.sample post-commit
- Change permissions of post-commit to be able to execute
chmod a+x post-commit