Easy Git Hooks with Husky

What are Git Hooks?

Git hooks are scripts that are executed before or after Git events such as: commit, push and receive. You can use these to increase your productivity as a developer in a number of ways. It’s amazing to automatically run unit tests when you commit and preventing it when a test fails, or notify your team when a commit has successfully been pushed.

Each Git project should have a .git/hooks directory where these hooks are stored.

Why use Husky?

The hooks inside the .git folder are stored locally so you will not be able to share it with your team. The files are also NOT written in JavaScript. When you’re like me who’s too lazy to learn a little shell scripting, then we’re in luck.

Husky is a tool for Node.js that allows you to manage your hooks from your package.json file. When you install Husky the first time, it will modify the files inside .git/hooks so when you trigger a Git event, it will call the corresponding script that you configured in your package.json.


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s