Find path to git hooks directory on the shell
git
Solution
You can use `git rev-parse --git-dir` to get the path to the repository used for your current directory. This will deal with gitlinks (using a file in place of the `.git` directory) as well as having use of the `$GIT_DIR` environment variable. The hooks directory will always be inside of that so you can use:
`git rev-parse --git-dir`/hooks
to get the path to the hooks directory.
This is documented in the git rev-parse manpage
Problem
How do I find the full path to the `.git/hooks` directory of the current Git repository? I see the following issues: Deep in the directory structure I may be anywhere deep in the git repository directory structure, e.g. ``` /home/user/project/.git/hooks ``` and I am in folder ``` /home/user/project/foo/bar/baz/ ``` Submodules Newer git versions put submodule meta data not into `.git/` but in the main repository and `.git` is only a file, e.g. ``` $ cat /home/user/project/vendor/foo/.git gitdir: ../../.git/modules/vendor/foo ``` So in this case, the hooks dir is in ``` /home/user/project/.git/modules/vendor/foo/hooks ```