Git Clients

pre-commit – framework for managing multi-language Git hooks

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 help

pre-commit is written in Python. Learn Python with our recommended free books and free tutorials.


Related Software

Git Hook Managers
lefthookGit hooks manager for Node.js, Ruby, Python and more
huskyGit hooks made easy
pre-commitManage and maintain multi-language pre-commit hooks
prekReimagined version of pre-commit
overcommitManage and configure Git hooks
hkGit hooks manager and project linting tool focusing on performance
simple-git-hooksSimple git hooks manager for small projects
CaptainHookFlexible Git hook manager
GithooksPlatform-independent hooks manager
git-hooksRewritten from icefox/git-hooks, with extra features
JigGit pre-commit hook on steroids

Read our verdict in the software roundup.


Best Free and Open Source Software 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.
Subscribe

Please read our Comment Policy before commenting.

Notify of
guest
0 Comments
Oldest
Newest Most Voted