提交后显示警告消息

时间:2011-05-16 19:15:57

标签: git

我想在有人提交更改后显示警告消息。

$ git commit -am "First commit"  # Or `git commit -a` and then type a message in the editor
Please, don't forget to update the production repository

我唯一的限制是它无法对所有Git存储库执行,它只能在特定目录中工作。

这可能吗?

1 个答案:

答案 0 :(得分:1)

您可以使用post-commit挂钩执行此操作。 documentation for that hook说:

  

发表提交

     

这个钩子由git commit调用。它不需要参数,并在提交后调用。此挂钩主要用于通知,不会影响git commit的结果。

...所以你可以安装一个post-commit钩子来回应你提到的消息。如何让用户安装此挂钩是另一回事,在Stack Overflow上的其他答案中有所涉及,例如: Can Git hook scripts be managed along with the repository? ....