Repository: pre-commit/pre-commit

Issue:
core.hooksPath being set makes it not possible to install
I have a laptop which has some mandaotry global settings for git, and I have not been able to enable pre-commit.  I also tried doing
```
git config --global init.templateDir ~/.git-template
pre-commit init-templatedir ~/.git-template
```
But still get the message
```
[ERROR] Cowardly refusing to install hooks with `core.hooksPath` set.
hint: `git config --unset-all core.hooksPath`
```

Is there any work arounds for this?

Discussion:

Patch:
diff --git a/pre_commit/commands/install_uninstall.py b/pre_commit/commands/install_uninstall.py
index 9372176..b2ccc5c 100644
--- a/pre_commit/commands/install_uninstall.py
+++ b/pre_commit/commands/install_uninstall.py
@@ -123,7 +123,7 @@ def install(
         skip_on_missing_config: bool = False,
         git_dir: Optional[str] = None,
 ) -> int:
-    if git.has_core_hookpaths_set():
+    if git_dir is None and git.has_core_hookpaths_set():
         logger.error(
             'Cowardly refusing to install hooks with `core.hooksPath` set.\n'
             'hint: `git config --unset-all core.hooksPath`',


Test patch:
diff --git a/tests/commands/init_templatedir_test.py b/tests/commands/init_templatedir_test.py
index 4e32e75..d14a171 100644
--- a/tests/commands/init_templatedir_test.py
+++ b/tests/commands/init_templatedir_test.py
@@ -79,3 +79,14 @@ def test_init_templatedir_expanduser(tmpdir, tempdir_factory, store, cap_out):
     lines = cap_out.get().splitlines()
     assert len(lines) == 1
     assert lines[0].startswith('pre-commit installed at')
+
+
+def test_init_templatedir_hookspath_set(tmpdir, tempdir_factory, store):
+    target = tmpdir.join('tmpl')
+    tmp_git_dir = git_dir(tempdir_factory)
+    with cwd(tmp_git_dir):
+        cmd_output('git', 'config', '--local', 'core.hooksPath', 'hooks')
+        init_templatedir(
+            C.CONFIG_FILE, store, target, hook_types=['pre-commit'],
+        )
+    assert target.join('hooks/pre-commit').exists()