← 返回命令列表

Linux command

prek 命令

文本

复制后可按需替换文件名、目录或参数。

常用示例

Install

prek install

Run

prek run

Run

prek run --all-files

Run

prek run [hook_id]

Auto-update

prek auto-update

List

prek list

Convert

prek util yaml-to-toml

Uninstall

prek uninstall

说明

prek is a Git hook manager designed as a faster, drop-in replacement for pre-commit. It reads the same _.pre-commit-config.yaml_ files and supports the same hook ecosystem, while shipping as a single static binary written in Rust with no Python runtime dependency. prek caches hook environments under _~/.cache/prek_ and reuses them across repositories. Several common hooks (file fixers, JSON/YAML validators, etc.) are reimplemented in Rust and run as built-ins, avoiding the cost of spawning interpreters. Toolchain installs for Python, Node.js, Bun, Go, Rust, and Ruby are shared across hooks, and Python environments are managed through uv. In addition to the legacy YAML schema, prek understands a native _prek.toml_ format and provides _prek util yaml-to-toml_ to migrate existing configurations. Workspace mode lets a single config drive hooks across multiple sub-projects in a monorepo, with --project and --skip-project filters on the command line.

参数

install --hook-type _type_ --overwrite
Install Git hooks into _.git/hooks_. Repeat --hook-type to install pre-commit, commit-msg, pre-push, etc.
uninstall --hook-type _type_
Remove previously installed hooks while leaving prek's cache intact.
run --all-files --files _path..._ --hook-stage _stage_ --from-ref _ref_ --to-ref _ref_ --last-commit --show-diff-on-failure --no-fail-fast _hook-id_
Execute hooks. With no arguments, runs against staged files; with --all-files, runs against every tracked file.
auto-update --check --bleeding-edge --freeze --cooldown-days _N_ --repo _url_
Update rev: entries in the configuration to the latest released tag. --check validates without rewriting.
list --hook-stage _stage_
Show the resolved list of hooks for the active configuration.
clean
Remove cached hook environments from prek's store.
gc
Garbage-collect unused repos from prek's cache.
init-templatedir _directory_
Populate a Git template directory so newly cloned repos pick up hooks automatically.
try-repo _repo_ --ref _ref_
Try a hook repository without modifying the project configuration.
util yaml-to-toml _path_
Convert _.pre-commit-config.yaml_ into the native _prek.toml_ format.
util list-builtins
List built-in hooks reimplemented in Rust.
util identify _file..._
Print the file types prek associates with the given paths (useful for debugging _types_ filters).
self update
Upgrade the prek binary itself to the latest release.
-c _file_, --config _file_
Use _file_ as the configuration instead of auto-discovery.
-v, --verbose
Increase log verbosity. Repeat for debug-level output.
-q, --quiet
Suppress non-essential output.
--color _when_
_auto_, _always_, or _never_.
-V, --version
Print the version and exit.

FAQ

What is the prek command used for?

prek is a Git hook manager designed as a faster, drop-in replacement for pre-commit. It reads the same _.pre-commit-config.yaml_ files and supports the same hook ecosystem, while shipping as a single static binary written in Rust with no Python runtime dependency. prek caches hook environments under _~/.cache/prek_ and reuses them across repositories. Several common hooks (file fixers, JSON/YAML validators, etc.) are reimplemented in Rust and run as built-ins, avoiding the cost of spawning interpreters. Toolchain installs for Python, Node.js, Bun, Go, Rust, and Ruby are shared across hooks, and Python environments are managed through uv. In addition to the legacy YAML schema, prek understands a native _prek.toml_ format and provides _prek util yaml-to-toml_ to migrate existing configurations. Workspace mode lets a single config drive hooks across multiple sub-projects in a monorepo, with --project and --skip-project filters on the command line.

How do I run a basic prek example?

Run `prek install` in a terminal, then adjust file names, paths, flags, or remote targets for your system.

What does install --hook-type _type_ --overwrite do in prek?

Install Git hooks into _.git/hooks_. Repeat --hook-type to install pre-commit, commit-msg, pre-push, etc.