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
A pre-commit hook for commitlint. Contribute to alessandrojcm/commitlint-pre-commit-hook development by creating an account on GitHub.
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.
🌐
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
🌐
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 ...
🌐
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?

🌐
GitHub
github.com › solarmonkey › commitlint-pre-commit-hook
GitHub - solarmonkey/commitlint-pre-commit-hook: A pre-commit hook for commitlint
A pre-commit hook for commitlint. Contribute to solarmonkey/commitlint-pre-commit-hook development by creating an account on GitHub.
Author   solarmonkey
🌐
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
🌐
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
🌐
Interrupt
interrupt.memfault.com › blog › pre-commit
Automatically format and lint code with pre-commit | Interrupt
October 27, 2021 - A useful command is pre-commit autoupdate, which will update all the checks to the latest tag! ... This file selects the hooks to be installed + used, and contains other configuration values such as paths to exclude from linting, etc.
🌐
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.
🌐
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
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. commitlint is a very helpful tool for enforcing a commit comment style.
Published   April 25, 2022
🌐
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 › glassblade › code-should-be-written-with-goals-in-mind-git-commitlint-c50758b85920
Code with Goals: git+commitlint. When used with automation software, Git… | by Daniel Tan | GlassBlade | Medium
May 9, 2020 - extends: -‘@ commitlint / config-conventional’ · 3. In the terminal, go to the root folder of the project and execute the following commands: pip install pre-commit pre-commit install — hook-type commit-msg pre-commit install
🌐
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 - Yes! Our commit message list is working!. Now lets try with the following commit lint which will work. Now run the following commit: ... BTW, you will get the linting formation in commitlint. So, here is the second part of our tutorial where we are going to implement the pre-commit hooks.
🌐
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.
🌐
Adarsha Acharya
adarsha.dev › blog › husky-commitlint-lint-staged
Pre-commit hooks with husky v6, commitlint and lint-staged | Adarsha Acharya
April 6, 2021 - Now create file named .lintstagedrc on our root directory and let us write configuration what we want the lint-staged to do before commits. You can setup below file as per your needs here I've setup lint-staged to run the eslint and prettier on src/ directory.
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.