Hooks not installed in the right hooks directory for worktrees
When on a git worktree, the hooks are not installed on the right hook dir:
```
❯ pre-commit install
pre-commit installed at /home/vampas/projects/SaltStack/console/raas/.git/worktrees/revan1/hooks/pre-commit
```
The hook does not run.

The hook only runs when I moved the `pre-commit` script to `/home/vampas/projects/SaltStack/console/raas/.git/hooks/pre-commit`

```
❯ pre-commit --version
pre-commit 1.10.4
```
diff --git a/pre_commit/git.py b/pre_commit/git.py
index 4fb2e65..d9e01f5 100644
--- a/pre_commit/git.py
+++ b/pre_commit/git.py
@@ -31,10 +31,16 @@ def get_root():
 
 
 def get_git_dir(git_root):
-    return os.path.normpath(os.path.join(
-        git_root,
-        cmd_output('git', 'rev-parse', '--git-dir', cwd=git_root)[1].strip(),
-    ))
+    def _git_dir(opt):
+        return os.path.normpath(os.path.join(
+            git_root,
+            cmd_output('git', 'rev-parse', opt, cwd=git_root)[1].strip(),
+        ))
+
+    try:
+        return _git_dir('--git-common-dir')
+    except CalledProcessError:  # pragma: no cover (git < 2.5)
+        return _git_dir('--git-dir')
 
 
 def get_remote_url(git_root):
diff --git a/tests/commands/install_uninstall_test.py b/tests/commands/install_uninstall_test.py
index 7345cfb..e6f0e41 100644
--- a/tests/commands/install_uninstall_test.py
+++ b/tests/commands/install_uninstall_test.py
@@ -172,6 +172,19 @@ def test_install_in_submodule_and_run(tempdir_factory, store):
         assert NORMAL_PRE_COMMIT_RUN.match(output)
 
 
+def test_install_in_worktree_and_run(tempdir_factory, store):
+    src_path = make_consuming_repo(tempdir_factory, 'script_hooks_repo')
+    path = tempdir_factory.get()
+    cmd_output('git', '-C', src_path, 'branch', '-m', 'notmaster')
+    cmd_output('git', '-C', src_path, 'worktree', 'add', path, '-b', 'master')
+
+    with cwd(path):
+        assert install(Runner(path, C.CONFIG_FILE), store) == 0
+        ret, output = _get_commit_output(tempdir_factory)
+        assert ret == 0
+        assert NORMAL_PRE_COMMIT_RUN.match(output)
+
+
 def test_commit_am(tempdir_factory, store):
     """Regression test for #322."""
     path = make_consuming_repo(tempdir_factory, 'script_hooks_repo')
['tests/commands/install_uninstall_test.py', 'pre_commit/git.py']