De aqui :
Name
post-commit — Notification of a successful commit.
Description
The post-commit hook is run after the transaction is committed, and a new revision created. Most people use this hook to send out descriptive emails about the commit or to notify some other tool (such as an issue tracker) that a commit has happened. Some configurations also use this hook to trigger backup processes.
The output from, and exit value returned by the post-commit hook program are ignored.
O que você deseja é um gancho de pré-compromisso (uma espécie de óbvio quando você pensa sobre esses nomes):
Name
pre-commit — Notification just prior to commit completion.
Description
The pre-commit hook is run just before a commit transaction is promoted to a new revision. Typically, this hook is used to protect against commits that are disallowed due to content or location (for example, your site might require that all commits to a certain branch include a ticket number from the bug tracker, or that the incoming log message is non-empty).
If the pre-commit hook program returns a non-zero exit value, the commit is aborted, the commit transaction is removed, and anything printed to stderr is marshalled back to the client.
Além disso, certifique-se de tornar o arquivo de script executável e use o nome exato pre-commit
ou post-commit
, ou seja, sem a extensão de nome de arquivo!