Reputation: 61
I have the following project structure and trying to change the default git hooks path from .git/hooks
to .githooks
. I found out that the command git config core.hooksPath .githooks
is responsible for this. But I've been struggling with the relative path in Windows 10, I need to go up 2 times and then specify .githooks
directory, but any ..\.
, ../.
, "..\."
doesn't work.
Maybe the problem not only in Windows but also the way how Git handles the config file, where this path will be written
How to specify such a path, for instance, in PowerShell?
Project directories:
|
└───.githooks <---I want it here
└───.git
│ └───hooks <---by default it's here
Solved: phd
suggested to use git config core.hooksPath ./.githooks
which works for windows
Upvotes: 1
Views: 828
Reputation: 94397
core.hooksPath
… can be … relative. A relative path is taken as relative to the directory where the hooks are run (see the "DESCRIPTION" section of githooks).
«Before Git invokes a hook, it changes its working directory to either $GIT_DIR in a bare repository or the root of the working tree in a non-bare repository.»
(Emphasize mine — phd).
To put your .githooks/
into the root you should provide a relative path to the root which is ./
. So use
git config core.hooksPath ./.githooks
Upvotes: 2