Git Hooks Reference Library

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

Use the Git Hooks Reference Library

Copied to clipboard

Summary

A browsable reference library of battle-tested Git hook scripts. Filter by hook type, search by keyword, and copy any script to your clipboard in one click. Every entry includes a plain-English description of what the hook does and when to use it.

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-05-23 · Reviewed by Nham Vu