pre-commit Hooks

Automation recipeIntermediate

Automatic checks before every commit: formatting, large files and private keys.

Steps

  1. Install the tool: pip install pre-commit.

  2. Create .pre-commit-config.yaml.

  3. Enable it: pre-commit install.

  4. Run it on all files: pre-commit run --all-files.

Example · yaml
repos:
  - repo: https://github.com/pre-commit/pre-commit-hooks
    rev: v6.0.0
    hooks:
      - id: check-added-large-files
      - id: detect-private-key
      - id: end-of-file-fixer
      - id: trailing-whitespace

Sources

  1. pre-commit framework