(01)Install pre-commit
Linux
1pip install pre-commit2# Or: sudo apt-get install pre-commitGit hooks that run linters and security checks before commit
What is this?
pre-commit installs Git hooks that run linters and formatters before each commit.
Where to create or edit the main configuration — paths below match the setup steps.
.pre-commit-config.yamlLocation: Repository root
Hooks — linters, formatters before commit
Step 01
1pip install pre-commit2# Or: sudo apt-get install pre-commitStep 02
1cat > .pre-commit-config.yaml << 'EOF'2repos:3 - repo: https://github.com/pre-commit/pre-commit-hooks4 rev: v4.6.05 hooks:6 - id: trailing-whitespace7 - id: check-yaml8EOF9pre-commit installStep 03
1pre-commit run --all-files