pre-commit is a framework for managing and maintaining Git hooks across projects written in different programming languages. It automates routine code checks before changes are committed, helping developers find formatting problems, common mistakes and other issues early.
Managing hooks manually can be awkward, particularly when contributors use different development environments. Some checking tools may require languages or dependencies that aren’t otherwise needed by the project. pre-commit addresses this by managing the environments required to run configured hooks.
Projects declare their checks in a configuration file, which can be committed to version control. Contributors then use the same definitions without having to maintain their own collection of hook scripts.
This is free and open source software.
Key Features
- Installs hooks defined in a .pre-commit-config.yaml file, with support for tools hosted in external repositories and locally defined commands.
- Automatically creates and caches isolated environments for supported languages, installing the dependencies required by individual hooks.
- Supports hooks written in Python, JavaScript, Ruby, Go, Rust and numerous other languages, together with system executables.
- Runs checks at different Git stages, including pre-commit, pre-push, commit-msg and prepare-commit-msg.
- Filters files using regular expressions, recognised file types and configurable inclusion or exclusion rules.
- Can process every file in a repository, selected files or an individual hook without creating a new commit.
- Supports additional hook dependencies, configurable arguments and specific language environments.
- Offers the pre-commit autoupdate command to update configured hook repositories and their pinned revisions.
- Includes options for stopping after a failed check, controlling output verbosity and writing hook failure logs.
- Can run the same checks in continuous integration pipelines to enforce consistent standards across contributors.
- Supports sharing custom hooks through repositories containing a .pre-commit-hooks.yaml manifest.
Website: github.com/pre-commit/pre-commit
Support:
Developer: Anthony Sottile, Ken Struys
License: MIT License
pre-commit is written in Python. Learn Python with our recommended free books and free tutorials.
Related Software
| Git Hook Managers | |
|---|---|
| lefthook | Git hooks manager for Node.js, Ruby, Python and more |
| husky | Git hooks made easy |
| pre-commit | Manage and maintain multi-language pre-commit hooks |
| GrumPHP | Automates PHP code quality checks through configurable Git hooks |
| prek | Reimagined version of pre-commit |
| overcommit | Manage and configure Git hooks |
| hk | Git hooks manager and project linting tool focusing on performance |
| simple-git-hooks | Simple git hooks manager for small projects |
| CaptainHook | Flexible Git hook manager |
| Githooks | Platform-independent hooks manager |
| git-hooks | Rewritten from icefox/git-hooks, with extra features |
| Autohook | Runs and organises Git hook scripts using a single Bash script |
| Jig | Git pre-commit hook on steroids |
Read our verdict in the software roundup.
LinuxLinks helps you discover the best free and open source software for Linux. Explore our extensive collection of recommended applications, including alternatives to popular proprietary software.We also publish software reviews, Linux tutorials, hardware reviews, free programming books and articles covering the wider open source community. Browse our Linux resources to discover more. Know a useful free and open source Linux application we haven't covered? Suggest a program for inclusion. Has your software been featured on LinuxLinks? Display one of our Featured on LinuxLinks badges on your website or GitHub README. |



Please read our Comment Policy before commenting.