CLI Reference¶
prek¶
A fast Git hook manager written in Rust, designed as a drop-in alternative to pre-commit, reimagined.
Usage
Commands
prek installInstall prek Git hook shims
prek prepare-hooksPrepare environments for configured hooks
prek runRun configured hooks
prek execRun a command in the environment prepared for a configured hook
prek listList configured hooks
prek uninstallUninstall prek Git hook shims
prek validate-configValidate prek configuration files
prek validate-manifestValidate pre-commit hook manifests (
.pre-commit-hooks.yaml)prek sample-configGenerate a sample prek configuration file
prek updateUpdate configured repositories
prek cacheManage the prek cache
prek try-repoTry hooks from a repository
prek utilRun utility commands
prek selfManage the prek installation
prek install¶
Install prek Git hook shims.
The effective hooks directory defaults to .git/hooks/, but repo-local or worktree-local core.hooksPath is honored when set.
The Git shims installed by this command are determined by --hook-type or default_install_hook_types in the config file, falling back to pre-commit when neither is set.
A hook's stages field does not affect which Git shims this command installs.
Usage
Arguments
HOOK|PROJECTInclude the specified hooks or projects.
Supports flexible selector syntax:
-
hook-id: Run all hooks with the specified ID across all projects -
project-path/: Run all hooks from the specified project -
project-path:hook-id: Run only the specified hook from the specified project
Can be specified multiple times to select multiple hooks/projects.
-
Options
--allow-missing-configAllow a missing configuration file
--cd,-CdirChange to directory before running
--colorcolorWhether to use color in output
May also be set with the
PREK_COLORenvironment variable.[default: auto]
Possible values:
auto: Enables colored output only when the output is going to a terminal or TTY with supportalways: Enables colored output regardless of the detected environmentnever: Disables colored output
--config,-cconfigPath to alternate config file
--force,--overwrite,-fForce installation and overwrite existing Git shims.
If
core.hooksPathis configured outside this repository, install the shims into this repository's default hooks directory.--git-dirgit-dirInstall Git shims into the
hookssubdirectory of the given git directory (<GIT_DIR>/hooks/).When this flag is used,
prek installbypasses the safety check that normally refuses to install shims whilecore.hooksPathis configured outside the repo. It only writes shims to<GIT_DIR>/hooks; Git will keep usingcore.hooksPathuntil that config changes.--help,-hDisplay the concise help for this command
--hook-type,-thook-typeWhich Git shim(s) to install.
Specifies which Git hook type(s) you want to install shims for. Can be specified multiple times to install shims for multiple hook types.
If not specified, uses
default_install_hook_typesfrom the config file, or defaults topre-commitif that is also not set.Note: This is different from a hook's
stagesparameter in the config file, which declares which stages a hook can run in.Possible values:
commit-msgpost-checkoutpost-commitpost-mergepost-rewritepre-commitpre-merge-commitpre-pushpre-rebaseprepare-commit-msg
--log-filelog-fileWrite trace logs to the specified file. If not specified, trace logs will be written to
$PREK_HOME/prek.log--no-progressHide all progress outputs.
For example, spinners or progress bars.
--prepare-hooks,--install-hooksAlso prepare environments for all hooks used in the config file
--quiet,-qUse quiet output.
Repeating this option, e.g.,
-qq, will enable a silent mode in which prek will write no output to stdout.May also be set with the
PREK_QUIETenvironment variable.--refreshRefresh all cached data
--skiphook|projectSkip the specified hooks or projects.
Supports flexible selector syntax:
-
hook-id: Skip all hooks with the specified ID across all projects -
project-path/: Skip all hooks from the specified project -
project-path:hook-id: Skip only the specified hook from the specified project
Can be specified multiple times. Also accepts
PREK_SKIPorSKIPenvironment variables (comma-delimited).-
--verbose,-vUse verbose output
--version,-VDisplay the prek version
prek prepare-hooks¶
Prepare environments for configured hooks.
This command does not install Git shims. To install the Git shims along with the hook environments in one command, use prek install --prepare-hooks.
Usage
Arguments
HOOK|PROJECTInclude the specified hooks or projects.
Supports flexible selector syntax:
-
hook-id: Run all hooks with the specified ID across all projects -
project-path/: Run all hooks from the specified project -
project-path:hook-id: Run only the specified hook from the specified project
Can be specified multiple times to select multiple hooks/projects.
-
Options
--cd,-CdirChange to directory before running
--colorcolorWhether to use color in output
May also be set with the
PREK_COLORenvironment variable.[default: auto]
Possible values:
auto: Enables colored output only when the output is going to a terminal or TTY with supportalways: Enables colored output regardless of the detected environmentnever: Disables colored output
--config,-cconfigPath to alternate config file
--help,-hDisplay the concise help for this command
--log-filelog-fileWrite trace logs to the specified file. If not specified, trace logs will be written to
$PREK_HOME/prek.log--no-progressHide all progress outputs.
For example, spinners or progress bars.
--quiet,-qUse quiet output.
Repeating this option, e.g.,
-qq, will enable a silent mode in which prek will write no output to stdout.May also be set with the
PREK_QUIETenvironment variable.--refreshRefresh all cached data
--skiphook|projectSkip the specified hooks or projects.
Supports flexible selector syntax:
-
hook-id: Skip all hooks with the specified ID across all projects -
project-path/: Skip all hooks from the specified project -
project-path:hook-id: Skip only the specified hook from the specified project
Can be specified multiple times. Also accepts
PREK_SKIPorSKIPenvironment variables (comma-delimited).-
--verbose,-vUse verbose output
--version,-VDisplay the prek version
prek run¶
Run configured hooks
Usage
Arguments
HOOK|PROJECTInclude the specified hooks or projects.
Supports flexible selector syntax:
-
hook-id: Run all hooks with the specified ID across all projects -
project-path/: Run all hooks from the specified project -
project-path:hook-id: Run only the specified hook from the specified project
Can be specified multiple times to select multiple hooks/projects.
-
Options
--all-files,-aRun hooks on all tracked files in the repository
--cd,-CdirChange to directory before running
--colorcolorWhether to use color in output
May also be set with the
PREK_COLORenvironment variable.[default: auto]
Possible values:
auto: Enables colored output only when the output is going to a terminal or TTY with supportalways: Enables colored output regardless of the detected environmentnever: Disables colored output
--config,-cconfigPath to alternate config file
--directory,-ddirRun hooks on tracked files under the specified directory.
Paths are resolved relative to the current working directory after applying
--cd. This option can be repeated and combined with--filesand--glob.--dry-runDo not run the hooks, but print the hooks that would have been run
--fail-fastStop running hooks after the first failure
--filesfilesRun hooks on the specified file paths.
Paths are resolved relative to the current working directory after applying
--cd. They may be tracked or untracked. This option accepts multiple paths and can be combined with--globand--directory.--from-ref,--source,-sfrom-refThe original ref in a
<from_ref>...<to_ref>diff expression. Files changed in this diff will be run through the hooks--globpatternRun hooks on tracked files matching the specified glob pattern.
Patterns are matched against paths relative to the current working directory after applying
--cd. Quote patterns to prevent shell expansion. This option can be repeated and combined with--filesand--directory.--groupgroupRun hooks belonging to the specified group.
Can be specified multiple times; a hook may match any specified group. When combined with
--require-group, both filters must match.--help,-hDisplay the concise help for this command
--last-commitRun hooks against the last commit. Equivalent to
--from-ref HEAD~1 --to-ref HEAD--log-filelog-fileWrite trace logs to the specified file. If not specified, trace logs will be written to
$PREK_HOME/prek.log--no-groupgroupDo not run hooks belonging to the specified group.
Can be specified multiple times. Exclusion wins over inclusion.
--no-progressHide all progress outputs.
For example, spinners or progress bars.
--quiet,-qUse quiet output.
Repeating this option, e.g.,
-qq, will enable a silent mode in which prek will write no output to stdout.May also be set with the
PREK_QUIETenvironment variable.--refreshRefresh all cached data
--require-groupgroupRun hooks belonging to every specified group.
Can be specified multiple times; a hook must match every specified group. When combined with
--group, it must also match at least one--group.--no-groupexcludes matching hooks regardless of argument order.For example,
--require-group fast --group format --group lint-onlyselects hooks infastand eitherformatorlint-only.--show-diff-on-failureWhen hooks fail, run
git diffdirectly afterward--skiphook|projectSkip the specified hooks or projects.
Supports flexible selector syntax:
-
hook-id: Skip all hooks with the specified ID across all projects -
project-path/: Skip all hooks from the specified project -
project-path:hook-id: Skip only the specified hook from the specified project
Can be specified multiple times. Also accepts
PREK_SKIPorSKIPenvironment variables (comma-delimited).-
--stage,--hook-stagestageThe stage during which the hook is fired.
When specified, only hooks configured for that stage (for example
manual,pre-commit, orpre-push) will run. When not specified and no group filter is active, this command starts with hooks eligible forpre-commit. If no hook is selected and the command named hook IDs, those same IDs are matched again against hooks configured formanual. With--group,--require-group, or--no-group, omitting the stage lets hooks from any configured stage match, using the default file input mode; hooks that only run atcommit-msgorprepare-commit-msgare ignored.Possible values:
manualcommit-msgpost-checkoutpost-commitpost-mergepost-rewritepre-commitpre-merge-commitpre-pushpre-rebaseprepare-commit-msg
--to-ref,--origin,-oto-refThe destination ref in a
from_ref...to_refdiff expression. Defaults toHEADiffrom_refis specified--verbose,-vUse verbose output
--version,-VDisplay the prek version
prek exec¶
Run a command in the environment prepared for a configured hook
Usage
Arguments
HOOKHook whose execution environment should be used.
Supports
hook-idandproject-path:hook-idselectors and must resolve to exactly one configured hook.COMMANDCommand and arguments to execute
Options
--cd,-CdirChange to directory before running
--colorcolorWhether to use color in output
May also be set with the
PREK_COLORenvironment variable.[default: auto]
Possible values:
auto: Enables colored output only when the output is going to a terminal or TTY with supportalways: Enables colored output regardless of the detected environmentnever: Disables colored output
--config,-cconfigPath to alternate config file
--help,-hDisplay the concise help for this command
--log-filelog-fileWrite trace logs to the specified file. If not specified, trace logs will be written to
$PREK_HOME/prek.log--no-progressHide all progress outputs.
For example, spinners or progress bars.
--quiet,-qUse quiet output.
Repeating this option, e.g.,
-qq, will enable a silent mode in which prek will write no output to stdout.May also be set with the
PREK_QUIETenvironment variable.--refreshRefresh all cached data
--verbose,-vUse verbose output
--version,-VDisplay the prek version
prek list¶
List configured hooks
Usage
Arguments
HOOK|PROJECTInclude the specified hooks or projects.
Supports flexible selector syntax:
-
hook-id: Run all hooks with the specified ID across all projects -
project-path/: Run all hooks from the specified project -
project-path:hook-id: Run only the specified hook from the specified project
Can be specified multiple times to select multiple hooks/projects.
-
Options
--cd,-CdirChange to directory before running
--colorcolorWhether to use color in output
May also be set with the
PREK_COLORenvironment variable.[default: auto]
Possible values:
auto: Enables colored output only when the output is going to a terminal or TTY with supportalways: Enables colored output regardless of the detected environmentnever: Disables colored output
--config,-cconfigPath to alternate config file
--groupgroupShow hooks belonging to the specified group.
Can be specified multiple times.
--help,-hDisplay the concise help for this command
--hook-stagehook-stageShow only hooks that has the specified stage
Possible values:
manualcommit-msgpost-checkoutpost-commitpost-mergepost-rewritepre-commitpre-merge-commitpre-pushpre-rebaseprepare-commit-msg
--languagelanguageShow only hooks that are implemented in the specified language
Possible values:
buncondacoursierdartdenodockerdocker-imagedotnetfailgolanghaskelljulialuamisenodeperlphppygreppythonrrubyrustscriptswiftsystem
--log-filelog-fileWrite trace logs to the specified file. If not specified, trace logs will be written to
$PREK_HOME/prek.log--no-groupgroupDo not show hooks belonging to the specified group.
Can be specified multiple times. Exclusion wins over inclusion.
--no-progressHide all progress outputs.
For example, spinners or progress bars.
--output-formatoutput-formatThe output format
[default: text]
Possible values:
textjson
--quiet,-qUse quiet output.
Repeating this option, e.g.,
-qq, will enable a silent mode in which prek will write no output to stdout.May also be set with the
PREK_QUIETenvironment variable.--refreshRefresh all cached data
--require-groupgroupShow hooks belonging to every specified group.
Can be specified multiple times. Composes with
--groupand--no-group.--skiphook|projectSkip the specified hooks or projects.
Supports flexible selector syntax:
-
hook-id: Skip all hooks with the specified ID across all projects -
project-path/: Skip all hooks from the specified project -
project-path:hook-id: Skip only the specified hook from the specified project
Can be specified multiple times. Also accepts
PREK_SKIPorSKIPenvironment variables (comma-delimited).-
--verbose,-vUse verbose output
--version,-VDisplay the prek version
prek uninstall¶
Uninstall prek Git hook shims
Usage
Options
--allUninstall all prek-managed Git shims.
Scans the hooks directory and removes every hook managed by prek, regardless of hook type.
--cd,-CdirChange to directory before running
--colorcolorWhether to use color in output
May also be set with the
PREK_COLORenvironment variable.[default: auto]
Possible values:
auto: Enables colored output only when the output is going to a terminal or TTY with supportalways: Enables colored output regardless of the detected environmentnever: Disables colored output
--config,-cconfigPath to alternate config file
--git-dirgit-dirUninstall Git shims from the
hookssubdirectory of the given git directory (<GIT_DIR>/hooks/).When this flag is used,
prek uninstallbypasses the safety check that normally refuses to modify shims whilecore.hooksPathis configured outside the repo. It only removes shims from<GIT_DIR>/hooks; Git may still use the configuredcore.hooksPathuntil that config changes.--help,-hDisplay the concise help for this command
--hook-type,-thook-typeWhich Git shim(s) to uninstall.
Specifies which Git hook type(s) you want to uninstall shims for. Can be specified multiple times to uninstall shims for multiple hook types.
If not specified, uses
default_install_hook_typesfrom the config file, or defaults topre-commitif that is also not set. Use--allto remove all prek-managed hooks.Possible values:
commit-msgpost-checkoutpost-commitpost-mergepost-rewritepre-commitpre-merge-commitpre-pushpre-rebaseprepare-commit-msg
--log-filelog-fileWrite trace logs to the specified file. If not specified, trace logs will be written to
$PREK_HOME/prek.log--no-progressHide all progress outputs.
For example, spinners or progress bars.
--quiet,-qUse quiet output.
Repeating this option, e.g.,
-qq, will enable a silent mode in which prek will write no output to stdout.May also be set with the
PREK_QUIETenvironment variable.--refreshRefresh all cached data
--verbose,-vUse verbose output
--version,-VDisplay the prek version
prek validate-config¶
Validate prek configuration files
Usage
Arguments
CONFIGThe path to the configuration file
Options
--cd,-CdirChange to directory before running
--colorcolorWhether to use color in output
May also be set with the
PREK_COLORenvironment variable.[default: auto]
Possible values:
auto: Enables colored output only when the output is going to a terminal or TTY with supportalways: Enables colored output regardless of the detected environmentnever: Disables colored output
--config,-cconfigPath to alternate config file
--help,-hDisplay the concise help for this command
--log-filelog-fileWrite trace logs to the specified file. If not specified, trace logs will be written to
$PREK_HOME/prek.log--no-progressHide all progress outputs.
For example, spinners or progress bars.
--quiet,-qUse quiet output.
Repeating this option, e.g.,
-qq, will enable a silent mode in which prek will write no output to stdout.May also be set with the
PREK_QUIETenvironment variable.--refreshRefresh all cached data
--verbose,-vUse verbose output
--version,-VDisplay the prek version
prek validate-manifest¶
Validate pre-commit hook manifests (.pre-commit-hooks.yaml)
Usage
Arguments
MANIFESTThe path to the manifest file
Options
--cd,-CdirChange to directory before running
--colorcolorWhether to use color in output
May also be set with the
PREK_COLORenvironment variable.[default: auto]
Possible values:
auto: Enables colored output only when the output is going to a terminal or TTY with supportalways: Enables colored output regardless of the detected environmentnever: Disables colored output
--config,-cconfigPath to alternate config file
--help,-hDisplay the concise help for this command
--log-filelog-fileWrite trace logs to the specified file. If not specified, trace logs will be written to
$PREK_HOME/prek.log--no-progressHide all progress outputs.
For example, spinners or progress bars.
--quiet,-qUse quiet output.
Repeating this option, e.g.,
-qq, will enable a silent mode in which prek will write no output to stdout.May also be set with the
PREK_QUIETenvironment variable.--refreshRefresh all cached data
--verbose,-vUse verbose output
--version,-VDisplay the prek version
prek sample-config¶
Generate a sample prek configuration file
Usage
Options
--cd,-CdirChange to directory before running
--colorcolorWhether to use color in output
May also be set with the
PREK_COLORenvironment variable.[default: auto]
Possible values:
auto: Enables colored output only when the output is going to a terminal or TTY with supportalways: Enables colored output regardless of the detected environmentnever: Disables colored output
--config,-cconfigPath to alternate config file
--file,-ffileWrite the sample config to a file.
Defaults to
.pre-commit-config.yamlunless--format tomlis set, which usesprek.toml. If a path is provided without--format, the format is inferred from the file extension (.tomluses TOML).--formatformatSelect the sample configuration format
Possible values:
yamltoml
--help,-hDisplay the concise help for this command
--log-filelog-fileWrite trace logs to the specified file. If not specified, trace logs will be written to
$PREK_HOME/prek.log--no-progressHide all progress outputs.
For example, spinners or progress bars.
--quiet,-qUse quiet output.
Repeating this option, e.g.,
-qq, will enable a silent mode in which prek will write no output to stdout.May also be set with the
PREK_QUIETenvironment variable.--refreshRefresh all cached data
--verbose,-vUse verbose output
--version,-VDisplay the prek version
prek update¶
Update configured repositories
Usage
Options
--bleeding-edgeUpdate to the bleeding edge of the default branch instead of the latest tagged version
--cd,-CdirChange to directory before running
--checkAlias of
--dry-run --exit-code--colorcolorWhether to use color in output
May also be set with the
PREK_COLORenvironment variable.[default: auto]
Possible values:
auto: Enables colored output only when the output is going to a terminal or TTY with supportalways: Enables colored output regardless of the detected environmentnever: Disables colored output
--config,-cconfigPath to alternate config file
--cooldown-daysdaysMinimum release age (in days) required for a version to be eligible.
The age is computed from the tag creation timestamp for annotated tags, or from the tagged commit timestamp for lightweight tags. If the current
revis newer than the latest cooldown-eligible tag,prek updatekeeps the currentrevinstead of downgrading it. Defaults toupdate.cooldown_daysin the project or global config, or0when unset. Valid values are0through255;0disables this check.--dry-runDo not write changes to the config file, only display what would be changed
--exclude-reporepoDo not update this repository. This option may be specified multiple times
--exclude-tagpatternIgnore tags matching this glob pattern. This option may be specified multiple times. Defaults to
update.exclude_tagsin the project or global config when unset.For example, use
--exclude-tag nightlyto skip a moving tag, or--exclude-tag '*-{alpha,beta,rc}*'to skip common prerelease tags.--exit-codeExit with status 1 if updates are available
--freezeStore "frozen" hashes in
revinstead of tag names. Defaults toupdate.freezein the project or global config, orfalsewhen unset--help,-hDisplay the concise help for this command
--include-tagpatternOnly consider tags matching this glob pattern. This option may be specified multiple times. Defaults to
update.include_tagsin the project or global config when unset.For example, use
--include-tag 'v*'to only consider version tags and ignore tags such asnightly.--jobs,-jjobsNumber of threads to use
[default: 0]
--log-filelog-fileWrite trace logs to the specified file. If not specified, trace logs will be written to
$PREK_HOME/prek.log--no-progressHide all progress outputs.
For example, spinners or progress bars.
--quiet,-qUse quiet output.
Repeating this option, e.g.,
-qq, will enable a silent mode in which prek will write no output to stdout.May also be set with the
PREK_QUIETenvironment variable.--refreshRefresh all cached data
--reporepoOnly update this repository. This option may be specified multiple times
--repo-exclude-tagrepo=patternIgnore tags matching this glob pattern for a repository (
<repo>=<pattern>). This option may be specified multiple times. Adds to the effectiveupdateexclude filters for the named repository.Repo-specific exclude filters are added to global
--exclude-tagfilters; matching either filter excludes the tag for that repository.For example, use
--repo-exclude-tag https://github.com/example/repo=nightlyor--repo-exclude-tag https://github.com/example/repo=*-rc*to skip nightly or prerelease tags for one repository.--repo-include-tagrepo=patternOnly consider tags matching this glob pattern for a repository (
<repo>=<pattern>). This option may be specified multiple times. Overrides the effective include filters for the named repository.When set for a repository, this overrides any global
--include-tagfilters for that repository.For example, use
--repo-include-tag https://github.com/example/repo=v*to only consider version tags for one repository.--verbose,-vUse verbose output
--version,-VDisplay the prek version
prek cache¶
Manage the prek cache
Usage
Commands
prek cache dirShow the location of the prek cache
prek cache gcRemove unused cached repositories, hook environments, and other data
prek cache cleanRemove all prek cached data
prek cache sizeShow the size of the prek cache
prek cache dir¶
Show the location of the prek cache
Usage
Options
--cd,-CdirChange to directory before running
--colorcolorWhether to use color in output
May also be set with the
PREK_COLORenvironment variable.[default: auto]
Possible values:
auto: Enables colored output only when the output is going to a terminal or TTY with supportalways: Enables colored output regardless of the detected environmentnever: Disables colored output
--config,-cconfigPath to alternate config file
--help,-hDisplay the concise help for this command
--log-filelog-fileWrite trace logs to the specified file. If not specified, trace logs will be written to
$PREK_HOME/prek.log--no-progressHide all progress outputs.
For example, spinners or progress bars.
--quiet,-qUse quiet output.
Repeating this option, e.g.,
-qq, will enable a silent mode in which prek will write no output to stdout.May also be set with the
PREK_QUIETenvironment variable.--refreshRefresh all cached data
--verbose,-vUse verbose output
--version,-VDisplay the prek version
prek cache gc¶
Remove unused cached repositories, hook environments, and other data
Usage
Options
--cd,-CdirChange to directory before running
--colorcolorWhether to use color in output
May also be set with the
PREK_COLORenvironment variable.[default: auto]
Possible values:
auto: Enables colored output only when the output is going to a terminal or TTY with supportalways: Enables colored output regardless of the detected environmentnever: Disables colored output
--config,-cconfigPath to alternate config file
--dry-runPrint what would be removed, but do not delete anything
--help,-hDisplay the concise help for this command
--log-filelog-fileWrite trace logs to the specified file. If not specified, trace logs will be written to
$PREK_HOME/prek.log--no-progressHide all progress outputs.
For example, spinners or progress bars.
--quiet,-qUse quiet output.
Repeating this option, e.g.,
-qq, will enable a silent mode in which prek will write no output to stdout.May also be set with the
PREK_QUIETenvironment variable.--refreshRefresh all cached data
--verbose,-vUse verbose output
--version,-VDisplay the prek version
prek cache clean¶
Remove all prek cached data
Usage
Options
--cd,-CdirChange to directory before running
--colorcolorWhether to use color in output
May also be set with the
PREK_COLORenvironment variable.[default: auto]
Possible values:
auto: Enables colored output only when the output is going to a terminal or TTY with supportalways: Enables colored output regardless of the detected environmentnever: Disables colored output
--config,-cconfigPath to alternate config file
--help,-hDisplay the concise help for this command
--log-filelog-fileWrite trace logs to the specified file. If not specified, trace logs will be written to
$PREK_HOME/prek.log--no-progressHide all progress outputs.
For example, spinners or progress bars.
--quiet,-qUse quiet output.
Repeating this option, e.g.,
-qq, will enable a silent mode in which prek will write no output to stdout.May also be set with the
PREK_QUIETenvironment variable.--refreshRefresh all cached data
--verbose,-vUse verbose output
--version,-VDisplay the prek version
prek cache size¶
Show the size of the prek cache
Usage
Options
--cd,-CdirChange to directory before running
--colorcolorWhether to use color in output
May also be set with the
PREK_COLORenvironment variable.[default: auto]
Possible values:
auto: Enables colored output only when the output is going to a terminal or TTY with supportalways: Enables colored output regardless of the detected environmentnever: Disables colored output
--config,-cconfigPath to alternate config file
--help,-hDisplay the concise help for this command
--human,--human-readable,-HDisplay the cache size in human-readable format (e.g.,
1.2GiBinstead of raw bytes)--log-filelog-fileWrite trace logs to the specified file. If not specified, trace logs will be written to
$PREK_HOME/prek.log--no-progressHide all progress outputs.
For example, spinners or progress bars.
--output-formatoutput-formatSelect the output format
[default: auto]
Possible values:
auto: Display a human-readable size in terminals and raw bytes otherwisehuman: Display the cache size in a human-readable formatmachine: Display the cache size in raw bytes
--quiet,-qUse quiet output.
Repeating this option, e.g.,
-qq, will enable a silent mode in which prek will write no output to stdout.May also be set with the
PREK_QUIETenvironment variable.--refreshRefresh all cached data
--verbose,-vUse verbose output
--version,-VDisplay the prek version
prek try-repo¶
Try hooks from a repository
Usage
Arguments
REPORepository to source hooks from
HOOK|PROJECTInclude the specified hooks or projects.
Supports flexible selector syntax:
-
hook-id: Run all hooks with the specified ID across all projects -
project-path/: Run all hooks from the specified project -
project-path:hook-id: Run only the specified hook from the specified project
Can be specified multiple times to select multiple hooks/projects.
-
Options
--all-files,-aRun hooks on all tracked files in the repository
--cd,-CdirChange to directory before running
--colorcolorWhether to use color in output
May also be set with the
PREK_COLORenvironment variable.[default: auto]
Possible values:
auto: Enables colored output only when the output is going to a terminal or TTY with supportalways: Enables colored output regardless of the detected environmentnever: Disables colored output
--config,-cconfigPath to alternate config file
--directory,-ddirRun hooks on tracked files under the specified directory.
Paths are resolved relative to the current working directory after applying
--cd. This option can be repeated and combined with--filesand--glob.--dry-runDo not run the hooks, but print the hooks that would have been run
--fail-fastStop running hooks after the first failure
--filesfilesRun hooks on the specified file paths.
Paths are resolved relative to the current working directory after applying
--cd. They may be tracked or untracked. This option accepts multiple paths and can be combined with--globand--directory.--from-ref,--source,-sfrom-refThe original ref in a
<from_ref>...<to_ref>diff expression. Files changed in this diff will be run through the hooks--globpatternRun hooks on tracked files matching the specified glob pattern.
Patterns are matched against paths relative to the current working directory after applying
--cd. Quote patterns to prevent shell expansion. This option can be repeated and combined with--filesand--directory.--help,-hDisplay the concise help for this command
--last-commitRun hooks against the last commit. Equivalent to
--from-ref HEAD~1 --to-ref HEAD--log-filelog-fileWrite trace logs to the specified file. If not specified, trace logs will be written to
$PREK_HOME/prek.log--no-progressHide all progress outputs.
For example, spinners or progress bars.
--quiet,-qUse quiet output.
Repeating this option, e.g.,
-qq, will enable a silent mode in which prek will write no output to stdout.May also be set with the
PREK_QUIETenvironment variable.--refreshRefresh all cached data
--rev,--refrevManually select a rev to run against, otherwise the
HEADrevision will be used--show-diff-on-failureWhen hooks fail, run
git diffdirectly afterward--skiphook|projectSkip the specified hooks or projects.
Supports flexible selector syntax:
-
hook-id: Skip all hooks with the specified ID across all projects -
project-path/: Skip all hooks from the specified project -
project-path:hook-id: Skip only the specified hook from the specified project
Can be specified multiple times. Also accepts
PREK_SKIPorSKIPenvironment variables (comma-delimited).-
--stage,--hook-stagestageThe stage during which the hook is fired.
When specified, only hooks configured for that stage (for example
manual,pre-commit, orpre-push) will run. When not specified, this command starts with hooks eligible forpre-commit. If no hook is selected and the command named hook IDs, those same IDs are matched again against hooks configured formanual.Possible values:
manualcommit-msgpost-checkoutpost-commitpost-mergepost-rewritepre-commitpre-merge-commitpre-pushpre-rebaseprepare-commit-msg
--to-ref,--origin,-oto-refThe destination ref in a
from_ref...to_refdiff expression. Defaults toHEADiffrom_refis specified--verbose,-vUse verbose output
--version,-VDisplay the prek version
prek util¶
Run utility commands
Usage
Commands
prek util identifyShow file identification tags
prek util list-builtinsList all built-in hooks bundled with prek
prek util init-template-dirInstall Git shims in a directory intended for use with
git config init.templateDirprek util yaml-to-tomlConvert a YAML configuration file to prek.toml
prek util identify¶
Show file identification tags
Usage
Arguments
PATHThe path(s) to the file(s) to identify
Options
--cd,-CdirChange to directory before running
--colorcolorWhether to use color in output
May also be set with the
PREK_COLORenvironment variable.[default: auto]
Possible values:
auto: Enables colored output only when the output is going to a terminal or TTY with supportalways: Enables colored output regardless of the detected environmentnever: Disables colored output
--config,-cconfigPath to alternate config file
--help,-hDisplay the concise help for this command
--log-filelog-fileWrite trace logs to the specified file. If not specified, trace logs will be written to
$PREK_HOME/prek.log--no-progressHide all progress outputs.
For example, spinners or progress bars.
--output-formatoutput-formatThe output format
[default: text]
Possible values:
textjson
--quiet,-qUse quiet output.
Repeating this option, e.g.,
-qq, will enable a silent mode in which prek will write no output to stdout.May also be set with the
PREK_QUIETenvironment variable.--refreshRefresh all cached data
--verbose,-vUse verbose output
--version,-VDisplay the prek version
prek util list-builtins¶
List all built-in hooks bundled with prek
Usage
Options
--cd,-CdirChange to directory before running
--colorcolorWhether to use color in output
May also be set with the
PREK_COLORenvironment variable.[default: auto]
Possible values:
auto: Enables colored output only when the output is going to a terminal or TTY with supportalways: Enables colored output regardless of the detected environmentnever: Disables colored output
--config,-cconfigPath to alternate config file
--help,-hDisplay the concise help for this command
--log-filelog-fileWrite trace logs to the specified file. If not specified, trace logs will be written to
$PREK_HOME/prek.log--no-progressHide all progress outputs.
For example, spinners or progress bars.
--output-formatoutput-formatThe output format
[default: text]
Possible values:
textjson
--quiet,-qUse quiet output.
Repeating this option, e.g.,
-qq, will enable a silent mode in which prek will write no output to stdout.May also be set with the
PREK_QUIETenvironment variable.--refreshRefresh all cached data
--verbose,-vUse verbose output
--version,-VDisplay the prek version
prek util init-template-dir¶
Install Git shims in a directory intended for use with git config init.templateDir
Usage
Arguments
DIRECTORYThe directory in which to write the Git shim
Options
--cd,-CdirChange to directory before running
--colorcolorWhether to use color in output
May also be set with the
PREK_COLORenvironment variable.[default: auto]
Possible values:
auto: Enables colored output only when the output is going to a terminal or TTY with supportalways: Enables colored output regardless of the detected environmentnever: Disables colored output
--config,-cconfigPath to alternate config file
--help,-hDisplay the concise help for this command
--hook-type,-thook-typeWhich Git shim(s) to install.
Specifies which Git hook type(s) you want to install shims for. Can be specified multiple times to install shims for multiple hook types.
If not specified, uses
default_install_hook_typesfrom the config file, or defaults topre-commitif that is also not set.Possible values:
commit-msgpost-checkoutpost-commitpost-mergepost-rewritepre-commitpre-merge-commitpre-pushpre-rebaseprepare-commit-msg
--log-filelog-fileWrite trace logs to the specified file. If not specified, trace logs will be written to
$PREK_HOME/prek.log--no-allow-missing-configAssume cloned repos should have a
pre-commitconfig--no-progressHide all progress outputs.
For example, spinners or progress bars.
--quiet,-qUse quiet output.
Repeating this option, e.g.,
-qq, will enable a silent mode in which prek will write no output to stdout.May also be set with the
PREK_QUIETenvironment variable.--refreshRefresh all cached data
--verbose,-vUse verbose output
--version,-VDisplay the prek version
prek util yaml-to-toml¶
Convert a YAML configuration file to prek.toml
Usage
Arguments
CONFIGThe YAML configuration file to convert. If omitted, discovers
.pre-commit-config.yamlor.pre-commit-config.ymlin the current directory
Options
--cd,-CdirChange to directory before running
--colorcolorWhether to use color in output
May also be set with the
PREK_COLORenvironment variable.[default: auto]
Possible values:
auto: Enables colored output only when the output is going to a terminal or TTY with supportalways: Enables colored output regardless of the detected environmentnever: Disables colored output
--config,-cconfigPath to alternate config file
--forceOverwrite the output file if it already exists
--help,-hDisplay the concise help for this command
--log-filelog-fileWrite trace logs to the specified file. If not specified, trace logs will be written to
$PREK_HOME/prek.log--no-progressHide all progress outputs.
For example, spinners or progress bars.
--output,-ooutputPath to write the generated prek.toml file. Defaults to
prek.tomlin the same directory as the input file--quiet,-qUse quiet output.
Repeating this option, e.g.,
-qq, will enable a silent mode in which prek will write no output to stdout.May also be set with the
PREK_QUIETenvironment variable.--refreshRefresh all cached data
--verbose,-vUse verbose output
--version,-VDisplay the prek version
prek self¶
Manage the prek installation
Usage
Commands
prek self updateUpdate prek
prek self update¶
Update prek
Usage
Arguments
TARGET_VERSIONUpdate to the specified version. If not provided, prek will update to the latest version
Options
--cd,-CdirChange to directory before running
--colorcolorWhether to use color in output
May also be set with the
PREK_COLORenvironment variable.[default: auto]
Possible values:
auto: Enables colored output only when the output is going to a terminal or TTY with supportalways: Enables colored output regardless of the detected environmentnever: Disables colored output
--config,-cconfigPath to alternate config file
--help,-hDisplay the concise help for this command
--log-filelog-fileWrite trace logs to the specified file. If not specified, trace logs will be written to
$PREK_HOME/prek.log--no-progressHide all progress outputs.
For example, spinners or progress bars.
--quiet,-qUse quiet output.
Repeating this option, e.g.,
-qq, will enable a silent mode in which prek will write no output to stdout.May also be set with the
PREK_QUIETenvironment variable.--refreshRefresh all cached data
--tokentokenA GitHub token for authentication. A token is not required but can be used to reduce the chance of encountering rate limits
May also be set with the
GITHUB_TOKENenvironment variable.--verbose,-vUse verbose output
--version,-VDisplay the prek version