Skip to content

Instantly share code, notes, and snippets.

@amsoell
Created February 21, 2018 12:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save amsoell/ada87ccc08c4277b384d0c164eebe108 to your computer and use it in GitHub Desktop.
Save amsoell/ada87ccc08c4277b384d0c164eebe108 to your computer and use it in GitHub Desktop.
Include last 5 commit messages and hashes in default Git commit message
#!/bin/sh
ORIG_MSG_FILE="$1"
TEMP=`mktemp /tmp/git-msg-custom`
trap "rm -f $TEMP" exit
LAST10=`git log --oneline -5 | sed -e 's/^/# /'`
(printf "\n\n# Last 5 Commits:\n%s \n\n" "$LAST10"; cat "$ORIG_MSG_FILE") > "$TEMP"
cat "$TEMP" > "$ORIG_MSG_FILE"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment