开发者

Display warning message after commit

开发者 https://www.devze.com 2023-03-06 02:51 出处:网络
I want to display a warning message after someone commits a change. $ git commit -am \"First commit\"# Or `git commit -a` and then type a message in the editor

I want to display a warning message after someone commits a change.

$ 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

The only restriction that I have is that it can't be done to all Git repositories, it has to work only in specific directories.

Is this possibl开发者_JAVA技巧e?


You can do this with a post-commit hook. The documentation for that hook says:

post-commit

This hook is invoked by git commit. It takes no parameter, and is invoked after a commit is made. This hook is meant primarily for notification, and cannot affect the outcome of git commit.

... so you can just install a post-commit hook that echos your message you mention. How you get your users to install this hook is a different matter, covered in other answers on Stack Overflow, e.g. Can Git hook scripts be managed along with the repository?....

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号