I have recently been writing git hooks for my project team. I would like to know if developers are making various commits locally, without following the standard commit message pattern. then they push those commits. Will there push fail because there commits weren’t following the pattern?
The desired result would be they are able to commit locally as they wish, then are forced to follow a structure way when they push back to the main corporate branch.
Thoughts? Is this the best practice?
The trick is: git hooks are not published (pushed/pulled)
So if your project members push to a bare repo where a server-side hook (
pre-receiveorupdate) check for the commit message pattern (which I am not sure it can be done), that push will fail.But the commit lives on the developer local repo and he/she still has to fix it (
git commit --amendif no other commits have already been done).It would be better to:
See template directory section of
git init.That way, they will fail quicker than on the server side (where n incorrect commits can be pushed, and will fail)
In other work, here a client-side hook would be more appropriate.