I’d make it part of merge checks. Can’t merge unless all the requirements are OK, if formatting/linting are requirements then it’s nice to see failed checks and know what requires fixing. Answer from serverhorror on reddit.com
🌐
GitHub
github.com › alessandrojcm › commitlint-pre-commit-hook
GitHub - alessandrojcm/commitlint-pre-commit-hook: A pre-commit hook for commitlint · GitHub
- repo: https://github.com/alessandrojcm/commitlint-pre-commit-hook rev: <latest tag> hooks: - id: commitlint stages: [commit-msg] additional_dependencies: ['@commitlint/config-angular']
Starred by 182 users
Forked by 18 users
🌐
Commitlint
commitlint.js.org › guides › local-setup.html
Guide: Local setup | commitlint
Since v8.0.0 commitlint won't output anything if there are no problems with your commit. (You can use the --verbose flag to get positive output) ... git commit -m "chore: lint on commitmsg" # husky > pre-commit No staged files match any of provided globs.
People also ask

How can you enforce customized conventional commits in your project?
commitlint is a very helpful tool for enforcing a commit comment style. Conventional commits offer a standard for git commit messages which add consistency over projects. As well as being useful to humans, they help with automated continuous integration tasks like generating change logs and SemVer versioning. You can set conventional commits as a base standard then, augment the rules to suite your project. For example, if you have a monorepo and want to make sure a scope is included in each commit, you can add a rule for this. You can even go further and specify a list of allowed scopes.
🌐
rodneylab.com
rodneylab.com › rodney lab home › rodney lab blog posts › rust blog posts
Rust CI Tooling: Clippy, commitlint, pre-commit and More | Rodney Lab
What Rust formatting and linting tools are there?
The Rust team ships cargo-check with Rustup. This checks your Rust code for errors without fully building it. In fact, it should be quicker than building the code, when you just want a quick check you have not messed something up. As well as cargo-check there is rustfmt as well as Clippy. While rustfmt just enforces the Rust standard for code formatting, Clippy goes a step further. It can help you write better Rust. It goes beyond cargo-check which just checks for errors. Clippy will offer tips. For example, it might suggest a map is a clearer way of writing a particular block. As well as
🌐
rodneylab.com
rodneylab.com › rodney lab home › rodney lab blog posts › rust blog posts
Rust CI Tooling: Clippy, commitlint, pre-commit and More | Rodney Lab
Can you integrate cargo-check, rustfmt and Clippy into your Rust CI process?
Yes, it is not too much hassle to add cargo-check and rustfmt together with Clippy into your continuous integration process. Using git hooks you can check your code is clean for all three tools on each commit. In fact, we have seen the pre-commit tool can be super helpful here. Adding pre-commit with a hook for the tools will help keep your repo polished whether working in a team or on your own pet project.
🌐
rodneylab.com
rodneylab.com › rodney lab home › rodney lab blog posts › rust blog posts
Rust CI Tooling: Clippy, commitlint, pre-commit and More | Rodney Lab
🌐
Reddit
reddit.com › r/devops › pre-commit vs pre-push vs ci/cd for linting and formatting?
r/devops on Reddit: pre-commit vs pre-push vs CI/CD for linting and formatting?
November 6, 2022 -

So, I generally use commits as a saving mechanism, but after adding a linting and formatting pre-commit hook, I do find myself committing less often. While this does help me catch syntax errors, and I guess I could argue that my commits are cleaner, this does seem to be a bit inconvenient. I think part of it is breaking the mold of what I'm used to, but I also wonder if I would be more productive if I moved it to a pre-push, or even to part of my CI pipeline (running before my tests). Does anyone have any recommendations?

🌐
Interrupt
interrupt.memfault.com › blog › pre-commit
Automatically format and lint code with pre-commit | Interrupt
October 27, 2021 - How to use pre-commit for automated linting, formatting, and styling firmware code by using Python, clang-format, clang-tidy, and prettier
🌐
Theodorus Clarence
theodorusclarence.com › shorts › husky-commitlint-prettier
Husky, Commitlint, and Prettier Configuration | theodorusclarence.com
It will initialize all of the needed files including a sample pre-commit hook. First, install the dev dependencies · yarn add -D @commitlint/config-conventional @commitlint/cli · Then, create a new file in the husky folder · .husky/commit-msg · npx --no-install commitlint --edit "$1" Create commitlint.config.js, you don't need to override the rules if you don't want to ·
🌐
PyPI
pypi.org › project › commitlint
commitlint
JavaScript is disabled in your browser. Please enable JavaScript to proceed · A required part of this site couldn’t load. This may be due to a browser extension, network issues, or browser settings. Please check your connection, disable any ad blockers, or try using a different browser
🌐
Manuel-vogel
manuel-vogel.de › posts › 2023-05-09-commitlint
commitlint - pre-commit or husky | Manuel Vogel
Here comes the wrap-up and also an example using pre-commit. I found automatic and recommended steps in their instruction. So here comes the condensed version with the commands · For a nodejs project with yarn as package manager you can use the following commands · npx husky-init && yarn echo -n "module.exports = { extends: ['@commitlint/config-conventional'] };" >> .commitlintrc.js yarn add --dev @commitlint/{cli,config-conventional} npx husky add .husky/commit-msg 'npx commitlint --edit $1'
Find elsewhere
🌐
GitHub
github.com › solarmonkey › commitlint-pre-commit-hook
GitHub - solarmonkey/commitlint-pre-commit-hook: A pre-commit hook for commitlint
- repo: https://github.com/solarmonkey/commitlint-pre-commit-hook rev: main hooks: - id: commitlint stages: [commit-msg]
Author   solarmonkey
🌐
Rodney Lab
rodneylab.com › rodney lab home › rodney lab blog posts › rust blog posts
Rust CI Tooling: Clippy, commitlint, pre-commit and More | Rodney Lab
Rust CI tooling: how you use can Clippy, commitlint, commitizen, rustfmt and pre-commit in your Rust project with conventional commits.
Published   April 25, 2022
🌐
DEV Community
dev.to › mahmudulhsn › install-husky-in-your-project-for-proper-commit-lint-with-pre-commit-hooks-25b2
Install Husky in your project for proper commit lint with pre-commit hooks - DEV Community
May 10, 2025 - Proper commit message help us to find the particular code as well as we can easily understand which code contain the commit. So int this tutorial, we are going to learn about few topic. There are: ... First of all, we need to install Husky. So let's start by installing Husky. To install Husky Run the following command. ... Next, create a file in your git root directory named .commitlintrc.json and add the following configuration:
🌐
GitHub
github.com › alessandrojcm › commitlint-pre-commit-hook › blob › master › README.md
commitlint-pre-commit-hook/README.md at master · alessandrojcm/commitlint-pre-commit-hook
A pre-commit hook for commitlint. Contribute to alessandrojcm/commitlint-pre-commit-hook development by creating an account on GitHub.
Author   alessandrojcm
🌐
Dani Lucaci
danilucaci.com › blog › how-to-lint-and-test-code-using-git-pre-commit-hooks
How to lint and test your code using git pre-commit hooks
August 26, 2020 - How to use Git hooks, husky and lint-staged to run scripts that run linting and testing tools before we make a commit or push code to a repo.
🌐
freeCodeCamp
freecodecamp.org › news › how-to-use-commitlint-to-write-good-commit-messages
How to Write Good Commit Messages with Commitlint
November 12, 2021 - Commitlint is a simple tool that lints your commit messages and makes sure they follow a set of rules. It runs as a husky pre-commit hook, that is, it runs before the code is committed and blocks the commit in case it fails the lint checks.
🌐
Medium
trishan9.medium.com › what-is-commitlint-why-to-use-how-to-setup-and-more-2832d50ccff3
What is Commitlint? Why to use? How to Setup and more | by Trishan Wagle | Medium
September 8, 2023 - Commitlint is a simple tool that lints your commit messages and makes sure they follow a set of rules. It runs as a husky pre-commit hook, that is, it runs before the code is committed and blocks the commit in case it fails the lint checks.
🌐
Jorisroovers
jorisroovers.com › gitlint › dev › commit_hooks
Commit hook Setup - Gitlint - Joris Roovers
gitlint can be configured as a plugin for the pre-commit git hooks framework.
🌐
Medium
medium.com › @achanandhi.m › what-is-git-pre-commit-hooks-husky-lint-staged-and-common-warnings-06d30f52b937
What is Git Pre-Commit Hooks: Husky, lint-staged, and Common Warnings | by Achanandhi M | Medium
February 24, 2025 - Enforces conventional commit messages using commitlint. lint-staged ensures that only staged files (files you added with git add) are checked and fixed before committing. This improves performance because it avoids running linters or formatters ...
Top answer
1 of 2
34

Taking commit-msg for example.

#!/bin/bash

MSG="$1"

if ! grep -qE "updated" "$MSG";then
    cat "$MSG"
    echo "Your commit message must contain the word 'updated'"
    exit 1
fi

chmod 755 commit-msg and copy it as .git/hooks/commit-msg.

2 of 2
3

You can use commitlint with git pre-commit hook.

The simplest way I found to use it is via pre-commit framework. The nice thing is that you can easily add and customize any other check before commiting, here's a list of supported hooks.

Adding commitlint with pre-commit

pip install pre-commit
or brew install pre-commit

Create your .pre-commit-config.yaml (check and update rev if needed):

repos:
- repo: https://github.com/alessandrojcm/commitlint-pre-commit-hook
  rev: v2.3.0
  hooks:
      - id: commitlint
        stages: [commit-msg]
        additional_dependencies: ['@commitlint/config-conventional']
        args: ["--config",".commitlintrc.yaml"]

You have a lot of options with a commitlint configuration file .commitlintrc.yaml:

rules:
  body-leading-blank: [1, always]
  body-max-line-length: [2, always, 100]
  footer-leading-blank: [1, always]
  footer-max-line-length: [2, always, 100]
  header-max-length: [2, always, 100]
  subject-case:
    - 2
    - never
    - [sentence-case, start-case, pascal-case, upper-case]
  subject-empty: [2, never]
  subject-full-stop: [2, never, "."]
  type-case: [2, always, lower-case]
  type-empty: [2, never]
  type-enum:
    - 2
    - always
    - [build, chore, ci, docs, feat, fix, perf, refactor, revert, style, test]

Install commit message hook pre-commit install --hook-type commit-msg

And then you can try to git commit.

You can also install commitlint directly via npm, here's how.

# Install commitlint cli and conventional config
npm install --save-dev @commitlint/{config-conventional,cli}

# Configure commitlint to use conventional config
echo "module.exports = {extends: ['@commitlint/config-conventional']}" > commitlint.config.js

I recommend Conventional Commits format.

The commit message should be structured as follows:

<type>[optional scope]: <description>

[optional body]

[optional footer(s)]

Default types: build, chore, ci, docs, feat, fix, perf, refactor, revert, style, test

Examples:

  • feat(parser): add ability to parse arrays
  • docs: correct spelling of CHANGELOG
  • ci: add docker build

Some benefits of using this structure:

  • Automatically generating CHANGELOGs.
  • Automatically determining a semantic version bump (based on the types of commits landed).
  • Communicating the nature of changes to teammates, the public, and other stakeholders.
🌐
Medium
iamshadi.medium.com › why-i-regret-using-pre-commit-hooks-and-why-you-should-too-04f79c52e142
Why I Regret Using Pre-Commit Hooks (and Why You Should Too) | by Shadi F | Medium
November 1, 2024 - I introduced git hooks. Specifically, a pre-commit hook that would auto-format our code, lint it, type check it and make sure everyone wrote perfect commit messages using Commitlint and Commitizen.