Skip to content

Instantly share code, notes, and snippets.

@windgazer
windgazer / prepare-commit-msg.sh
Last active January 8, 2019 14:04 — forked from bartoszmajsak/prepare-commit-msg.sh
How to automatically prepend git commit with a branch name. TLDR, from the root of each repository you want to use this, install using `curl -L https://goo.gl/5Mmuoi -o .git/hooks/prepare-commit-msg --create-dirs; chmod 744 .git/hooks/prepare-commit-msg`
#!/bin/bash
# To update or install in a new repository, run the following command
# N=.git/hooks/prepare-commit-msg ; curl -L https://goo.gl/5Mmuoi -o $N --create-dirs; chmod 744 $N
# Assuming all branches are created as `WWW-nnn-Human-readable-suffixes`
# this commit-msg hook will prepend all commit messages with the ticket
# name/number, for example:
# Branch: ADV-007-License-to-kill
# Message: Bad guy has been identified.