pre-commit-run - Man Page

pre-commit-run – Run hooks

Synopsis

pre-commit run [-h] [--color {auto,always,never}] [-c CONFIG] [--verbose] [--all-files | --files [FILES ...]] [--show-diff-on-failure] [--hook-stage {commit-msg,post-checkout,post-commit,post-merge,post-rewrite,pre-commit,pre-merge-commit,pre-push,pre-rebase,prepare-commit-msg,manual}] [--remote-branch REMOTE_BRANCH] [--local-branch LOCAL_BRANCH] [--from-ref FROM_REF] [--to-ref TO_REF] [--pre-rebase-upstream PRE_REBASE_UPSTREAM] [--pre-rebase-branch PRE_REBASE_BRANCH] [--commit-msg-filename COMMIT_MSG_FILENAME] [--prepare-commit-message-source PREPARE_COMMIT_MESSAGE_SOURCE] [--commit-object-name COMMIT_OBJECT_NAME] [--remote-name REMOTE_NAME] [--remote-url REMOTE_URL] [--checkout-type CHECKOUT_TYPE] [--is-squash-merge IS_SQUASH_MERGE] [--rewrite-command REWRITE_COMMAND] [hook]

Options

Positional Arguments

hook

A single hook-id to run.

Optional Arguments

-h--help

Show a help message and exit.

--color {auto,always,never}

Whether to use color in output. Defaults to auto.

-c,  --config CONFIG

Path to alternate config file.

--verbose,  -v
--all-files,  -a

Run on all the files in the repo.

--files [FILES ...]

Specific filenames to run hooks on.

--show-diff-on-failure

When hooks fail, run git-diff(1) directly afterward.

--hook-stage {commit-msg,post-checkout,post-commit,post-merge,post-rewrite,pre-commit,pre-merge-commit,pre-push,pre-rebase,prepare-commit-msg,manual}]

The stage during which the hook is fired. One of commit-msg, post-checkout, post-commit, post-merge, post-rewrite, pre-commit, pre-merge-commit, pre-push, pre-rebase, prepare-commit-msg, manual.

--remote-branch REMOTE_BRANCH

Remote branch ref used by git-push(1).

--local-branch LOCAL_BRANCH

Local branch ref used by git-push(1).

--from-ref,  --source,  -s FROM_REF

(For usage with --to-ref) – this option represents the original ref in a from_ref...to_ref diff expression. For pre-push hooks, this represents the branch you are pushing to. For post-checkout hooks, this represents the branch that was previously checked out.

--to-ref,  --origin,  -o TO_REF

(For usage with --from-ref) – this option represents the destination ref in a from_ref...to_ref diff expression. For pre-push hooks, this represents the branch being pushed. For post-checkout hooks, this represents the branch that is now checked out.

--pre-rebase-upstream PRE_REBASE_UPSTREAM

The upstream from which the series was forked.

--pre-rebase-branch PRE_REBASE_BRANCH

The branch being rebased, and is not set when rebasing the current branch.

--commit-msg-filename COMMIT_MSG_FILENAME

Filename to check when running during commit-msg.

--prepare-commit-message-source PREPARE_COMMIT_MESSAGE_SOURCE

Source of the commit message (typically the second argument to .git/hooks/prepare-commit-msg)

--commit-object-name COMMIT_OBJECT_NAME

Commit object name (typically the third argument to .git/hooks/prepare-commit-msg)

--remote-name REMOTE_NAME

Remote name used by git-push(1).

--remote-url REMOTE_URL

Remote url used by git-push(1).

--checkout-type CHECKOUT_TYPE

Indicates whether the checkout was a branch checkout (changing branches, flag=1) or a file checkout (retrieving a file from the index, flag=0).

--is-squash-merge IS_SQUASH_MERGE

During a post-merge hook, indicates whether the merge was a squash merge

--rewrite-command REWRITE_COMMAND

During a post-rewrite hook, specifies the command that invoked the rewrite

See Also

pre-commit-autoupdate(1), pre-commit-clean(1), pre-commit-gc(1), pre-commit-init-templatedir(1), pre-commit-install(1), pre-commit-install-hooks(1), pre-commit-migrate-config(1), pre-commit-sample-config(1), pre-commit-try-repo(1), pre-commit-uninstall(1), pre-commit-validate-config(1), pre-commit-validate-manifest(1), pre-commit-help(1)

pre-commit(1)

git-diff(1) git-push(1)

Referenced By

pre-commit(1), pre-commit-autoupdate(1), pre-commit-clean(1), pre-commit-gc(1), pre-commit-help(1), pre-commit-init-templatedir(1), pre-commit-install(1), pre-commit-install-hooks(1), pre-commit-migrate-config(1), pre-commit-sample-config(1), pre-commit-try-repo(1), pre-commit-uninstall(1), pre-commit-validate-config(1), pre-commit-validate-manifest(1).

February 2025