Git Hooks Reference Library

Browse common pre-commit, commit-msg, and pre-push hook scripts with copy-ready bash code.

Copied to clipboard

Summary

Browse common pre-commit, commit-msg, and pre-push hook scripts with copy-ready bash code.

How it works

  1. Select a hook type (pre-commit, commit-msg, pre-push, or all) to filter the library.
  2. Use the search box to find hooks by name or description keyword.
  3. Click any card to expand the full bash script.
  4. Click "Copy Script" to copy the ready-to-use code to your clipboard.
  5. Drop the script into your project's .git/hooks/ folder and make it executable with chmod +x.

Use cases

  • Enforce code formatting with ESLint, Prettier, or Black before every commit.
  • Block commits that contain debug statements, TODO comments, or API keys.
  • Validate commit message format to keep the git log readable.
  • Run a test suite before a push reaches the remote repository.
  • Prevent direct pushes to protected branches like main or master.

Frequently Asked Questions

Last updated: 2026-06-09 · Reviewed by Nham Vu