Skip to content

Instantly share code, notes, and snippets.

@gfontenot
Created June 23, 2012 01:13
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gfontenot/2976099 to your computer and use it in GitHub Desktop.
Save gfontenot/2976099 to your computer and use it in GitHub Desktop.
Post commit hook for Day One
#!/bin/sh
#
# Originally by Gordon Fontenot
# gordon.fontenot@me.com
#
# Log all commit messages to Day One
msg=`cat $PWD/.git/COMMIT_EDITMSG`
_pwd=`echo $PWD | sed -e "s/.*\///"`
_commit=`git rev-parse --short HEAD`
_branch=`git name-rev HEAD 2> /dev/null | sed 's#HEAD\ \(.*\)#\1#' `
# Edit this line with the path to your logging script
~/code/dotfiles/bin/dayone.rb "Commit to $_pwd _($_commit@$_branch)_\n\n$msg"

Setup

  • Edit the line noted to point to your logging script
  • Save this file as post-commit inside the git directory's .git/hooks directory
  • Make sure to chmod +x .git/hooks/post-commit
  • That's it.

Now, any time you make a commit for that repo, you'll get a nicely formatted Day One log entry formatted like so:

Commit to REPO_NAME (SHA1@BRANCH)

Your commit message here

It works awesome with single line commits from the command line, and even works with github.app for crafting nicer, longer commit messages. And any markdown in your commit message will be properly formatted inside Day One as well.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment