Back to Mise

`mise generate git-pre-commit`

docs/cli/generate/git-pre-commit.md

2026.8.41.5 KB
Original Source
<!-- @generated by usage-cli from usage spec -->

mise generate git-pre-commit

Generate a git pre-commit hook

This command generates a git pre-commit hook that runs a mise task like mise run pre-commit when you commit changes to your repository.

Staged files are passed to the task as STAGED.

For more advanced pre-commit functionality, see mise's sister project: https://hk.jdx.dev/

Arguments

[-- MISE_ARG]…

mise flags to embed in the generated hook, given after --

These are inserted between mise and run, so the hook carries the same context you would pass on the command line. Useful when the config is not at the repository root, since git runs hooks from the top level: -- -C subdir makes the hook find it.

Flags

-t --task <TASK>

The task to run when the pre-commit hook is triggered

Default: pre-commit

-w --write

write to .git/hooks/pre-commit and make it executable

--hook <HOOK>

Which hook to generate (saves to .git/hooks/$hook)

Default: pre-commit

Examples:

$ mise generate git-pre-commit --write --task=pre-commit
$ git commit -m "feat: add new feature" # runs `mise run pre-commit`

# config lives in a subdirectory, so the hook has to change into it first
$ mise generate git-pre-commit --write -- -C subdir