- Automate code style checks.
- Prevent committing broken code.
- Run security and linting checks.
- Ensure code consistency across the team.
Ensure you have Git and Python installed. Python version 3.10 is required to be installed for a correct functionality.
pip install pre-commitAlternatively, install using Homebrew (macOS/Linux):
brew install pre-commit
Verify the installation by running:
pre-commit run --all-filesRun the following command inside your repository to set up pre-commit:
pre-commit installThis will configure Git to trigger the hooks before each commit.
Pre-commit runs automatically when you issue git commands as git commit and git push. Any issues found have to be corrected before you can commit your changes locally and push them to Github.
To manually check your files without committing, run:
pre-commit run --all-filesIf necessary, you can bypass pre-commit checks when committing:
git commit --no-verify
⚠️ Use this only when absolutely necessary, as it skips all configured checks.
To update all installed hooks to their latest versions, run:
pre-commit autoupdatePre-commit hooks are configured in the .pre-commit-config.yaml Following checks are configured to run:
pre-commit:
- id: check-yaml
- id: end-of-file-fixer
- id: trailing-whitespace
- id: check-added-large-files
- id: check-case-conflict
- id: check-toml
- id: mixed-line-ending
- id: shellcheck
- id: talisman-commit
- id: typos
- id: dockerfilelint
pre-commit message:
- id: commitizen
pre-push:
- id: untracked-files