Quick start to Git Hooks

Raghav Bang
Published in
2 min readJan 22


Enforce code quality and increase productivity.

Git hooks are a powerful feature that allow you to trigger actions in response to certain events that occur in your remote repository and local repository. These events can be things like commits, push, pull requests, or even issues.

There are two types of groups in git hooks.

  1. Server-side hooks: runs on remote repository.
  2. Client-side hooks: runs on local repository.

Server-side hooks are executed before or after certain action happens on remote repository.

One of the most common use cases for Server-side Git hooks is to automate your build and deployment process. For example, you can configure a hook to automatically build and deploy your code whenever a new commit is pushed to the master branch.

You can also use Server-side Git hooks to integrate with other tools and services. For example, you can configure a hook to notify your team in a Slack channel whenever a pull request is opened, or a new issue is created.

To set Server-side Git hooks, you will need to navigate to the settings page of your repository, select the “Hooks” tab, and then configure the hook with the events and actions that you want to trigger.

Client-side hooks are executed before or after certain actions happens on local repository.

And for Client-side Git hooks popular use case is to automatically run UT’s / linting checks whenever code is pushed or a pull request is opened. This can help catch potential issues before they make it into production and ensure that your code is always in a releasable state.

To set Client-side Git hooks, you need to configure required hook file in .git/hooks folder on your local repository.

Pre-commit hook, post-commit hook, pre-receive hook and post-receive hook are more popular.

Why to use Git hooks?

  1. Increases productivity.
  2. Helps to automate to run custom script.
  3. Saves developer time.
  4. Reduces failure of build on remote, by checking lint/UT issues before commit.


Git hooks are a powerful feature that can help automate your workflow and integrate with other tools and services. It’s definitely worth taking the time to explore what they can do and how they can improve your development process.

If you like this post and find it helpful you can give me claps and do, follow me😍!!