Git submodule commit hooks

Mladen picture Mladen · Jun 1, 2012 · Viewed 9.9k times · Source

I'm using a git submodule (let's call it SubmoduleRepo) so that I can include my module in couple of projects.

I can commit to SubmoduleRepo from any project that uses it.

I can update, commit and push to SubmoduleRepo pretty hassle-free.

I need to execute a commit hook whenever I commit something while working in a directory in a project that contains the SubmoduleRepo (when I work in SubmoduleRepo, the commit hook executes as expected)

There is no .git folder in submodule's dir (only .git file that specifies path to current directory).

Answer

Jason Axelson picture Jason Axelson · Feb 28, 2013

If you have Git 2.10+ you can get the hooks directory by running:

`git rev-parse --git-path hooks`

Note: by default it is .git/hooks but if you are in a submodule it will be different.

Pre Git 2.10+ you would want something like:

`git rev-parse --git-dir`/hooks

More info at: Find path to git hooks directory on the shell