# pre-commit

> Framework for managing and maintaining multi-language pre-commit hooks in Git repositories.

Stars: 15.7k · Language: Python · License: MIT · Categories: Git

- Repository: https://github.com/pre-commit/pre-commit
- Website: https://pre-commit.com
- Page: https://www.trmn.sh/tools/pre-commit

## Overview

pre-commit is a framework that manages and executes pre-commit hooks across multiple programming languages in Git repositories. It allows developers to define a configuration file that specifies which hooks to run before each commit, automating code quality checks, formatting, and validation tasks.

The tool supports hooks written in various languages and can automatically install dependencies for each hook in isolated environments. This ensures that code quality tools like linters, formatters, and security scanners run consistently across different development environments without requiring manual setup of each tool.

Developers and teams use pre-commit to enforce coding standards and catch issues before code enters the repository. The framework integrates with existing Git workflows and can be configured to run different sets of hooks for different file types or project requirements.

## Alternatives

- [yadm](https://www.trmn.sh/tools/yadm.md): Dotfiles manager built on Git, with per-system alternate and templated files, encryption via GnuPG/OpenSSL/transcrypt/git-crypt, bootstrapping, and hooks. (Python, 6.5k stars)
- [git-lfs](https://www.trmn.sh/tools/git-lfs.md): Git extension for managing large files by storing them outside the repository with pointer files (Go, 14.6k stars)
- [git-secrets](https://www.trmn.sh/tools/git-secrets.md): Prevents committing passwords and sensitive information to git repositories using pattern matching and hooks (Shell, 13.4k stars)
- [tig](https://www.trmn.sh/tools/tig.md): ncurses-based text-mode interface for browsing Git repositories and staging changes (C, 13.4k stars)
- [diff-so-fancy](https://www.trmn.sh/tools/diff-so-fancy.md): Perl script that reformats git diff and unified diff output for readability, with cleaner headers, hunk markers, and stripped +/- symbols. (Perl, 18.1k stars)

## Guides

- [Find leaked secrets in a git repo with gitleaks](https://www.trmn.sh/guides/scan-repo-for-secrets-gitleaks): Scan git history and working files for API keys and tokens with gitleaks, allowlist false positives, add a pre-commit hook and run it in CI.
- [Best Tools for Testing and Linting Shell Scripts](https://www.trmn.sh/best/shell-script-quality-tools): Compare ShellCheck, Bats-core, pre-commit: workflows, strengths and tradeoffs.

---

Canonical: https://www.trmn.sh/tools/pre-commit
