Book Image

Git Best Practices Guide

By : PIDOUX Eric
Book Image

Git Best Practices Guide

By: PIDOUX Eric

Overview of this book

Table of Contents (12 chapters)

Git hooks


Git has a way to execute scripts when a Git command is performed. It will help you to perform some automated actions while you or one of your team members executes a Git command. The uses of these scripts are unlimited and very easy to set up. It will be very helpful to get notifications, format code, deploy websites, perform tasks on folders, and so on.

There are two types of hooks, depending on the commands:

  • Client hooks: These kinds of hooks are for client operations, such as the commit or merge command

  • Server hooks: These hooks are for Git server-side operations, such as the push command

Client hooks

There are many types of hooks for the client side; we choose to present the two most-known kinds. The first hook, pre-commit, works with the committing process. Firstly, the pre-commit hook is run before typing a commit message. It is used to inspect what you will commit, and it will be interesting to inspect your code to check that you forget nothing.

The commit is aborted if your...