🌐
pre-commit
pre-commit.com
pre-commit
The first time pre-commit runs on a file it will automatically download, install, and run the hook. Note that running a hook for the first time may be slow. For example: If the machine does not have node installed, pre-commit will download and build a copy of node.
🌐
GitHub
github.com › pre-commit › pre-commit-hooks
GitHub - pre-commit/pre-commit-hooks: Some out-of-the-box hooks for pre-commit · GitHub
- repo: https://github.com/pre-commit/pre-commit-hooks rev: v6.0.0 # Use the ref you want to point at hooks: - id: trailing-whitespace # - id: ...
Starred by 6.5K users
Forked by 789 users
Languages   Python
🌐
Git
git-scm.com › book › en › v2 › Customizing-Git-Git-Hooks
Git - Git Hooks
Exiting non-zero from this hook aborts the commit, although you can bypass it with git commit --no-verify. You can do things like check for code style (run lint or something equivalent), check for trailing whitespace (the default hook does exactly this), or check for appropriate documentation on new methods. The prepare-commit-msg hook is run before the commit message editor is fired up but after the default message is created.
🌐
Atlassian
atlassian.com › git › tutorials › git-hooks
Git Hooks | Atlassian Git Tutorial
December 16, 2025 - Or, if you’re writing a new script from scratch, you can simply add a new file matching one of the above filenames, minus the .sample extension. As an example, try installing a simple prepare-commit-msg hook.
🌐
GitHooks
githooks.com
Git Hooks - A Guide for Programmers
These hook scripts are only limited by a developer's imagination. Some example hook scripts include: pre-commit: Check the commit message for spelling errors.
🌐
GitKraken
help.gitkraken.com › gitkraken-client › githooksexample
Pre-Commit Hook Example in GitKraken Client | Git Hooks Example
June 28, 2024 - This pre-commit hook watches for incorrect commit authors and unsigned commits using the script below.
🌐
Medium
medium.com › data-science › custom-pre-commit-hooks-for-safer-code-changes-d8b8aa1b2ebb
Custom pre-commit hooks for safer code changes | by Thierry Jean | TDS Archive | Medium
March 14, 2024 - The preferred way of working with pre-commit hooks is through the pre-commit Python library. We can set it up with the following steps: Create a git repository for your project with git init · Install the pre-commit library with pip install pre-commit · Add a .pre-commit-config.yaml to your repository. Here’s an example:
🌐
Stefanie Molin
stefaniemolin.com › articles › devx › pre-commit › setup-guide
How to Set Up Pre-Commit Hooks | Stefanie Molin
December 7, 2025 - There are other docstring formats, but since I wrote this hook, I’ll feature it here 😊 For this section, we use the exclude key to instruct pre-commit not to run this hook on any files in the tests/ or docs/ directories: - repo: https://github.com/numpy/numpydoc rev: v1.6.0 hooks: - id: numpydoc-validation exclude: (tests|docs)/.* Example setup for the numpydoc-validation pre-commit hook.
Find elsewhere
🌐
Apache
hamilton.apache.org › how-tos › pre-commit-hooks
pre-commit hooks - Hamilton - Apache Software Foundation
A pre-commit hook is a script or command that’s executed automatically before making a commit. The goal of these hooks is to standardize code formatting and catch erroneous code before being committed. For example, popular hooks include ensuring files have no syntax errors, sorting imports, ...
🌐
Stefanie Molin
stefaniemolin.com › articles › devx › pre-commit › hook-creation-guide
Pre-Commit Hook Creation Guide | Stefanie Molin
September 1, 2025 - Be sure to add something like this to your README so people can easily include your hook in their .pre-commit-config.yaml files: - repo: https://github.com/stefmolin/filename-validation rev: 0.1.2 hooks: - id: validate-filename · The README is also a good spot to document any configuration options your hook supports (like the --min-len option). Often, this is done by providing an additional usage example:
🌐
Git
git-scm.com › docs › githooks
Git - githooks Documentation
This hook is invoked by git-merge[1], and can be bypassed with the --no-verify option. It takes no parameters, and is invoked after the merge has been carried out successfully and before obtaining the proposed commit log message to make a commit. Exiting with a non-zero status from this script causes the git merge command to abort before creating a commit. The default pre-merge-commit hook, when enabled, runs the pre-commit hook, if the latter is enabled.
🌐
Prettier
prettier.io › docs › precommit
Pre-commit Hook · Prettier
This will install husky and lint-staged, then add a configuration to the project’s package.json that will automatically format supported files in a pre-commit hook.
🌐
GitHub
github.com › pre-commit › pre-commit
GitHub - pre-commit/pre-commit: A framework for managing and maintaining multi-language pre-commit hooks. · GitHub
A framework for managing and maintaining multi-language pre-commit hooks. - pre-commit/pre-commit
Starred by 15.2K users
Forked by 961 users
Languages   Python 97.4% | R 2.0% | Shell 0.5% | Dockerfile 0.1% | Lua 0.0% | Ruby 0.0%
🌐
Hatica
hatica.io › blog › pre-commit-git-hooks
8 Pre-commit Git Hooks You Must Know for Improved Productivity - Hatica
May 25, 2023 - With pre-commit hooks, you can ... to understand across the codebase. For example, pre-commit hooks can be used to check for indentation, spacing, line breaks, and naming ......
🌐
GitHub
github.com › astral-sh › ruff-pre-commit
GitHub - astral-sh/ruff-pre-commit: A pre-commit hook for Ruff. · GitHub
repos: - repo: https://github.com/astral-sh/ruff-pre-commit # Ruff version. rev: v0.15.12 hooks: # Run the linter. - id: ruff-check types_or: [ python, pyi, jupyter, pyproject ] args: [ --fix ] # Run the formatter.
Starred by 1.9K users
Forked by 96 users
Languages   Python
🌐
Medium
gatlenculp.medium.com › effortless-code-quality-the-ultimate-pre-commit-hooks-guide-for-2025-57ca501d9835
Effortless Code Quality: The Ultimate Pre-Commit Hooks Guide for 2025
February 9, 2025 - While extensive tests may be too time consuming for a pre-commit hook, it can be helpful to run fast local tests to detect unexpected failures in your code before you are 10 commits in and unsure which one broke your code. The example below uses pytest. The first hook checks that the tests don’t contain any syntax errors and can be successfully collected.
🌐
GitHub
gist.github.com › samhemelryk › 8857553
A git pre-commit hook example. · GitHub
February 28, 2019 - A git pre-commit hook example. GitHub Gist: instantly share code, notes, and snippets.
🌐
Medium
medium.com › @0xmatriksh › how-to-setup-git-hooks-pre-commit-commit-msg-in-my-project-11aaec139536
How to setup git hooks(pre-commit, commit-msg) in my project? | by Kishmat | Medium
August 4, 2023 - Also it is important to consider and understand that you need to run pre-commit install whenever you change any configuration. Now next time you try to commit your changes the hooks will be triggered and it checks your code to ensure it is fine.
🌐
Git Scripts
gitscripts.com › git-pre-commit-hook-example
Git Pre Commit Hook Example: A Quick Guide to Automation
January 29, 2026 - Pre-commit hooks can be used to prevent a variety of issues, including: Linting code to enforce coding standards. Running tests to ensure that new changes don’t break existing functionality.