July 2018
Intermediate to advanced
354 pages
10h 57m
English
You can extend the functionality of the prepare-commit-msg hook easily, but you should bear in mind that the waiting time for fetching some information should be worth the benefits. One thing that is usually easy to check is a dirty work area.
Here, we need to use the git status command in the prepare commit message hook, and we need to predict whether we will have modified files after the commit:
$ git status On branch master nothing to commit, working directory clean
$ echo "saltwater" >> fishtank.txt
$ git status --porcelain M fishtank.txt ...
Read now
Unlock full access