Posted on Mon 17 June 2013

Experimenting with Git Hooks

I have been trying to follow a more disciplined approach to branching in my projects to allow easier tracking and regression. For example, I learnt that it's a good idea to prefix branch names with category tokens, such as feature/, bug/, or chore/. This allows us to use wildcards when listing branches:

$> git branch --list bug/*
$> git branch --list feature/*
feature/X49972617

Since I use Pivotal Tracker, I name my branches <type>/X<story-id>, and then use a simple hook to prepend all of my commit messages with the story ID.

$> git commit
[#49972617]
# Please enter the commit message for your changes. Lines starting
# with '#' will be ignored, and an empty message aborts the commit.
# On branch feature/X49972617

Category: Software

Tags: bash, git

Jim LimGitHubLinkedInStackOverflowontoplist ⋅ Theme by Giulio Fidente.