Abstract


  • A script or program located in .git/hooks File Directory that can be triggered at certain points in the Git workflow
  • These hooks allow you to customize and automate actions before or after specific events, such as committing changes, pushing to a repository, or merging branches
  • If the script doesn’t exit 0, the commit is aborted
  • We can use tools like Husky to have an easier time managing git hooks

Benefits


  • Useful for enforcing coding standards, running tests, or performing other checks to maintain the quality and consistency of a codebase

Husky


  • A tool that makes working with Git Hook easier, requires the NPM
  • npx husky-init && npm install to have husky that is managing a script that runs npm test before every commit. Detailed can be found here
  • More configurations can be found here