title: Find path to git hooks directory on the shell
body: <p>How do I find the full path to the <code>.git/hooks</code> directory of the current Git repository?</p>
  
  <hr>
  
  <p>I see the following issues:</p>
  
  <h2>Deep in the directory structure</h2>
  
  <p>I may be anywhere deep in the git repository directory structure, e.g.</p>
  
  <pre><code>/home/user/project/.git/hooks
  </code></pre>
  
  <p>and I am in folder</p>
  
  <pre><code>/home/user/project/foo/bar/baz/
  </code></pre>
  
  <h2>Submodules</h2>
  
  <p>Newer git versions put submodule meta data not into <code>.git/</code> but in the main repository and <code>.git</code> is only a file, e.g.</p>
  
  <pre><code>$ cat /home/user/project/vendor/foo/.git
  gitdir: ../../.git/modules/vendor/foo
  </code></pre>
  
  <p>So in this case, the hooks dir is in </p>
  
  <pre><code>/home/user/project/.git/modules/vendor/foo/hooks
  </code></pre>