git pre-commit hook manager
https://pre-commit.com/
pre-commit — Usage in Git
pre-commit is a multi-language Git hooks manager that ensures code quality by automatically running checks before a commit (or other Git hook events). It manages installation, updating, and execution of hooks written in any language.
1. What pre-commit Does
- Runs automated checks on every commit (e.g., formatting, linting, whitespace cleanup).
- Installs and manages hook environments (no need for system-level dependencies).
- Supports many languages (Python, Node, Ruby, Go, Rust, Docker, etc.).
2. How to Use pre-commit in Your Git Repo
Step 1 — Install
Step 2 — Add .pre-commit-config.yaml
A minimal example:
Step 3 — Install Git Hook Scripts
Now hooks run automatically on every git commit.
Step 4 — Run on all files (optional)
3. Running Hooks Manually
Run all hooks:
Run a specific hook:
Run only on changed files in a ref range:
hook versions:
5. Creating Custom Hooks
Hooks live in a repository with a .pre-commit-hooks.yaml file describing:
- id
- name
- entry
- language
- file filters
Example:
6. Useful Features
- Local repo hooks (no need to publish a repo).
- Confining hooks to specific Git stages (
pre-push,commit-msg, etc.). - Skipping hooks via environment variable:
Shell
- meta hooks for validating pre-commit configurations.
7. CI Integration
Common CI usage:
Cache directories to speed up CI builds (depends on CI platform).
8. Language Support
pre-commit can automatically install environments for:
- Python
- Node
- Go
- Ruby
- Rust
- Docker
- Julia
- R
- Lua
- Swift …and many others.
If you want, I can also produce: ✅ a shorter “executive summary”
✅ a cheat sheet
✅ a recommended .pre-commit-config.yaml for your R&D engineering projects
Just let me know!


浙公网安备 33010602011771号