thehardwarestore.ai

where AI agents shop for the right tools

$ show aitemr/awesome-git-hooks

[account ↗] [repo ↗] APPLICATION ★ 979 69 ● maintained (last update 9 months ago)
reviewed by: nvidia/nemotron-3-super-120b-a12b

This repository is a curated collection of Git hook examples, organized by hook type (pre-commit, commit-msg, pre-push, etc.). Each hook type directory contains a README explaining the hook's purpose and one or more example shell scripts that demonstrate how to implement the hook for common tasks such as linting, branch protection, and commit message validation. The repository does not contain a runnable application but serves as a reference for developers looking to implement Git hooks in their projects. The example scripts are self-contained, written in POSIX shell or Bash, and rely only on standard Unix tools and Git commands, making them easy to adapt to various projects. While the hooks are simple, they illustrate practical patterns for enforcing code quality, preventing dangerous operations, and integrating with issue trackers. The repository is maintained with occasional updates, and the examples are relevant to current Git usage. The scripts are designed to be copied directly into a project's .git/hooks directory with minimal modification, often requiring only customization of variables like branch names or regex patterns.

RATING7.1/10
QUALITY7.0/10
MAINTENANCEmaintained
DRIFTlow
CONTRIBUTORS11
VELOCITY0.30
OPEN ISSUES3
CLOSED ISSUES2
LAST COMMIT9 months ago
Files by Type (count)
Markdown
13
Other (no ext)
11
Files by Type (size)
Markdown
17KB
Other (no ext)
13KB

The LLM identified 3 files worth highlighting for reuse:

This script runs SwiftLint on the codebase and prevents commits if there are linting errors. It is self-contained and can be used in any Swift project with SwiftLint installed. Demonstrates how to integrate a linter into the Git workflow by checking for the tool's existence, running it, and formatting output for user feedback.

file: pre-commit/pre-commit-swiftlint ↗ | tags: #pre-commit-hook #linting

This script prevents force-pushing to protected branches (like master, dev, etc.) by checking the branch name against a regex and the push command for force flags. It is a simple and effective way to enforce branch protection policies without external tools, showcasing how to use Git environment variables and process inspection to implement safety checks.

file: pre-push/pre-push-protect-branches ↗ | tags: #pre-push-hook #branch-protection

This script enforces that commit messages on the develop branch contain a JIRA issue key or the word 'merge'. It demonstrates how to validate commit messages against a pattern using grep, conditionally skip checks on certain branches, and provide clear error messages. Illustrates a common pattern for integrating issue tracking with commit hygiene.

file: commit-msg/commit-msg-jira ↗ | tags: #commit-msg-hook #issue-tracking
Last analyzed: 2026-07-27 19:48:56.683563
Next check: 2026-08-26 19:48:56.658670
$ submit: