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
GrumPHPAutomates PHP code quality checks through configurable Git 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
AutohookRuns and organises Git hook scripts using a single Bash script
JigGit pre-commit hook on steroids

Read our verdict in the software roundup.


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

Please read our Comment Policy before commenting.

Notify of
guest
0 Comments
Oldest
Newest Most Voted