git provides a few hooks so you can control the workflow of your source code commits. These hooks are placed inside your
.git/hooks directory, and a inside there are a few samples to look at.
For my Ruby on Rails applications, I use the git pre-commit hook, to ensure that my Ruby code syntax is correct, and that it passes all my RSpec tests.
In your application directory, create a file in the git directory:
Don’t forget to make it executable:
chmod u+x .git/hooks/pre-commit
Now you are ready to go.