Variable: magit-overriding-githook-directory
magit-overriding-githook-directory is a customizable variable defined
in magit-git.el.
Value
nil
Documentation
Directory containing the Git hook scripts used by Magit.
No Magit-specific Git hook scripts are used if this is nil, which it is the default. This feature is still experimental.
Git does not allow overriding just an individual hook. It is only
possible to point Git at an alternative directory containing hook
scripts, using the Git variable core.hooksPath. When doing that,
the hooks located in $GIT_DIR/hooks are ignored.
If magit, use the directory containing Git hook scripts distributed
with Magit. To counteract Git's limited granularity, Magit provides a
script for every Git hook, most of which only run the respective script
located in $GIT_DIR/hooks, provided it exists and is executable.
A few Git hooks additionally run Lisp hooks:
- post-commit runs magit-git-post-commit-functions
- post-merge runs magit-git-post-merge-functions
- post-rewrite runs magit-git-post-rewrite-functions
All of these hooks also run magit-common-git-post-rewrite-functions.
For many uses this hook variable is more useful than the three above.
If you want to teach additional Git hooks to run Lisp hooks, you have to copy Magit's hook script directory elsewhere, modify the hook scripts in question, and point this variable at the used directory.
Magit only sets core.hooksPath when calling Git asynchronously. Doing
the same when calling Git synchronously would cause Git and Magit to wait
on one another.
This variable was added, or its default value changed, in magit version 4.5.0.
Source Code
;; Defined in ~/.emacs.d/elpa/magit-20260411.1452/magit-git.el
(defcustom magit-overriding-githook-directory nil
"Directory containing the Git hook scripts used by Magit.
No Magit-specific Git hook scripts are used if this is nil, which it
is the default. This feature is still experimental.
Git does not allow overriding just an individual hook. It is only
possible to point Git at an alternative directory containing hook
scripts, using the Git variable `core.hooksPath'. When doing that,
the hooks located in `$GIT_DIR/hooks' are ignored.
If `magit', use the directory containing Git hook scripts distributed
with Magit. To counteract Git's limited granularity, Magit provides a
script for every Git hook, most of which only run the respective script
located in `$GIT_DIR/hooks', provided it exists and is executable.
A few Git hooks additionally run Lisp hooks:
- `post-commit' runs `magit-git-post-commit-functions'
- `post-merge' runs `magit-git-post-merge-functions'
- `post-rewrite' runs `magit-git-post-rewrite-functions'
All of these hooks also run `magit-common-git-post-rewrite-functions'.
For many uses this hook variable is more useful than the three above.
If you want to teach additional Git hooks to run Lisp hooks, you have to
copy Magit's hook script directory elsewhere, modify the hook scripts in
question, and point this variable at the used directory.
Magit only sets `core.hooksPath' when calling Git asynchronously. Doing
the same when calling Git synchronously would cause Git and Magit to wait
on one another."
:package-version '(magit . "4.5.0")
:group 'magit-process
:set (lambda (symbol value)
(set-default-toplevel-value symbol value)
(setq magit--overriding-githook-directory nil))
:type '(choice (const :tag "Do not shadow Git's hook directory" nil)
(const :tag "Use Magit's hook directory" magit)
(directory :tag "Custom directory")))