2

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 possible?

Palec
  • 12,743
  • 8
  • 69
  • 138
Frias
  • 10,991
  • 9
  • 33
  • 40

1 Answers1

1

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?....

Community
  • 1
  • 1
Mark Longair
  • 446,582
  • 72
  • 411
  • 327