Home

Prepend Jira Ticket to Git Commits using Git hooks

November 5, 2017

One Line Installation

HOOKF=.git/hooks/prepare-commit-msg; if [ -d .git/hooks ] &&  [ ! -f $HOOKF ]; then curl -s https://gist.githubusercontent.com/khoi/e3d2cc8bceefdcd7bda32a337c978e32/raw > $HOOKF && chmod 755 $HOOKF; else echo "Can't install hook"; fi

TLDR Explaination

If you’re using Jira as your issue tracker, it’s probably a good idea to use the Smart Commit feature to link the Git commits to the tickets.

Remap CapsLock to Ctrl

Adding those ticket numbers to commit message is an error-prone process, and you might end up with the commits being linked to the wrong Jira issue.

Install the snippet below as your Git prepare-commit hook and you’ll have the ticket id automatically prepend to all your commits.