Skip to content

Instantly share code, notes, and snippets.

@leonid-ed
Last active April 28, 2016 08:00
Show Gist options
  • Save leonid-ed/fb88044aa5daa143849b005ad38346d4 to your computer and use it in GitHub Desktop.
Save leonid-ed/fb88044aa5daa143849b005ad38346d4 to your computer and use it in GitHub Desktop.
.git/hooks/prepare-commit-msg showing latest 15 commit messages
# The MIT License (MIT)
# Copyright (c) 2016 Leonid Edrenkin
#
#!/bin/bash
case "$2,$3" in
message,HEAD)
;;
*)
# obtain commit history
c_history=$(git log -15 --pretty=format:'%s' \
--abbrev-commit --date=relative | perl -lne 'print "# $_"')
echo -e "# Recent commit messages:" >> "$1"
echo -e "$c_history" >> "$1"
;;
esac
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment