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 |
| 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 |
| Jig | Git pre-commit hook on steroids |
Read our verdict in the software roundup.
Explore our carefully curated directory of recommended free and open source software, covering every major software category.The directory forms part of our extensive collection of articles for Linux enthusiasts. It includes hundreds of detailed reviews, together with free and open source alternatives to proprietary software from companies such as Google, Microsoft, Apple, Adobe, IBM, Cisco, Oracle, and Autodesk. LinuxLinks also covers interesting projects worth exploring, Linux-compatible hardware, free programming books and tutorials, and much more. Know a useful free and open source Linux application that we haven’t covered? Tell us about it using our submission form. |



Please read our Comment Policy before commenting.