In helping software teams double their productivity, one of the tools that we all use as software developers that gets the least attention is source control. If you’re using git, there are numerous features sitting there, waiting to help you develop software with less friction. One feature that I’m particularly enamored with are git hooks. Git hooks are automation scripts that fire when certain events happen in git, allowing you to automate otherwise manual activities.
Git hooks allow you to do the following:
- ensure branch names are consistent across individuals
- separate whitespace commits (formatting) from substantive commits
- update your ALM’s (JIRA, TFS, Gitlab) status automatically on commits with certain properties (e.g., a commit saying “fixed bug” triggers a workflow move from ‘in progress’ to ‘in review’ for a given bug)
- trigger checks to ensure copyright/license information is included in commits for new files
and so much more.
If you can write a script for it, you can automate it in git — and due to the nature of git, those hooks stay with the repository, no matter who pulls your code.