Skip to content

prek install -f fails when global core.hooksPath is set #2426

Closed

Description

@lxl66566

When git's core.hooksPath is configured globally, running prek install -f inside a repository produces the following error:

❯ prek install -f
error: Refusing to install hooks because core.hooksPath is configured outside this repository.

note: Git will execute hooks from the configured global/system hooks directory, not from this repository's hooks directory.

The -f (force) flag does not override this check.

Why do we need to install the hook? Because even if core.hooksPath is set, the local hook can still be executed via the global hook, such as the following pre-commit script:

#!/usr/bin/env bash

LOCAL_HOOK=".git/hooks/pre-commit"

if [ -f "$LOCAL_HOOK" ] && [ -x "$LOCAL_HOOK" ]; then
    "$LOCAL_HOOK" "$@"
    exit "$?"
fi

exit 0

The expected behavior is that -f would bypass the error and proceed with the installation, and simply emit a warning about the global hooksPath interfering.

Alternatively, if you made prek install (without -f) emit a warning about core.hooksPath instead of throwing an error, I would be even happier.

Activity

  1. added a commit that references this issue on Jul 31, 2026
    3ac4f9e
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions