diff --git a/pre_commit/commands/install_uninstall.py b/pre_commit/commands/install_uninstall.py
index c84d29b..47c9484 100644
--- a/pre_commit/commands/install_uninstall.py
+++ b/pre_commit/commands/install_uninstall.py
@@ -48,6 +48,9 @@ def install(runner, overwrite=False, hooks=False, hook_type='pre-commit'):
     hook_path = runner.get_hook_path(hook_type)
     legacy_path = hook_path + '.legacy'
 
+    if not os.path.exists(os.path.dirname(hook_path)):
+        os.makedirs(os.path.dirname(hook_path))
+
     # If we have an existing hook, move it to pre-commit.legacy
     if (
         os.path.exists(hook_path) and

Some versions of git don't create .git/hooks directory
Noticed here: https://github.com/victorlin/bugbuzz-python/pull/1#issuecomment-104971132
diff --git a/tests/commands/install_uninstall_test.py b/tests/commands/install_uninstall_test.py
index 9e1806e..ca82c06 100644
--- a/tests/commands/install_uninstall_test.py
+++ b/tests/commands/install_uninstall_test.py
@@ -5,6 +5,7 @@ import io
 import os
 import os.path
 import re
+import shutil
 import subprocess
 import sys
 
@@ -78,6 +79,15 @@ def test_install_pre_commit(tmpdir_factory):
     assert pre_push_contents == expected_contents
 
 
+def test_install_hooks_directory_not_present(tmpdir_factory):
+    path = git_dir(tmpdir_factory)
+    # Simulate some git clients which don't make .git/hooks #234
+    shutil.rmtree(os.path.join(path, '.git', 'hooks'))
+    runner = Runner(path)
+    install(runner)
+    assert os.path.exists(runner.pre_commit_path)
+
+
 def test_uninstall_does_not_blow_up_when_not_there(tmpdir_factory):
     path = git_dir(tmpdir_factory)
     runner = Runner(path)

pip install -e .[dev]
parse_log_pytest
requirements.txt
pytest
apt-get update apt-get install -y gcc
3.5
requirements-dev.txt
pytest --no-header -rA --tb=line --color=no -p no:cacheprovider -W ignore::DeprecationWarning
aspy.yaml==1.3.0
astroid==1.3.2
attrs==22.2.0
cached-property==1.5.2
certifi==2021.5.30
coverage==6.2
distlib==0.3.9
filelock==3.4.1
flake8==5.0.4
importlib-metadata==4.8.3
importlib-resources==5.4.0
iniconfig==1.1.1
jsonschema==3.2.0
logilab-common==1.9.7
mccabe==0.7.0
mock==5.2.0
mypy-extensions==1.0.0
nodeenv==1.6.0
ordereddict==1.1
packaging==21.3
platformdirs==2.4.0
pluggy==1.0.0
-e git+https://github.com/pre-commit/pre-commit.git@b4bc5e47423635e187d50d8730584d2c8ff06772#egg=pre_commit
py==1.11.0
pycodestyle==2.9.1
pyflakes==2.5.0
pylint==1.3.1
pyparsing==3.1.4
pyrsistent==0.18.0
pytest==7.0.1
PyYAML==6.0.1
simplejson==3.20.1
six==1.17.0
tomli==1.2.3
typing_extensions==4.1.1
virtualenv==20.17.1
zipp==3.6.0

name: pre-commit
channels:
  - defaults
  - https://repo.anaconda.com/pkgs/main
  - https://repo.anaconda.com/pkgs/r
  - conda-forge
dependencies:
  - _libgcc_mutex=0.1=main
  - _openmp_mutex=5.1=1_gnu
  - ca-certificates=2025.2.25=h06a4308_0
  - certifi=2021.5.30=py36h06a4308_0
  - ld_impl_linux-64=2.40=h12ee557_0
  - libffi=3.3=he6710b0_2
  - libgcc-ng=11.2.0=h1234567_1
  - libgomp=11.2.0=h1234567_1
  - libstdcxx-ng=11.2.0=h1234567_1
  - ncurses=6.4=h6a678d5_0
  - openssl=1.1.1w=h7f8727e_0
  - pip=21.2.2=py36h06a4308_0
  - python=3.6.13=h12debd9_1
  - readline=8.2=h5eee18b_0
  - setuptools=58.0.4=py36h06a4308_0
  - sqlite=3.45.3=h5eee18b_0
  - tk=8.6.14=h39e8969_0
  - wheel=0.37.1=pyhd3eb1b0_0
  - xz=5.6.4=h5eee18b_1
  - zlib=1.2.13=h5eee18b_1
  - pip:
      - argparse==1.4.0
      - aspy-yaml==1.3.0
      - astroid==1.3.2
      - attrs==22.2.0
      - cached-property==1.5.2
      - coverage==6.2
      - distlib==0.3.9
      - filelock==3.4.1
      - flake8==5.0.4
      - importlib-metadata==4.8.3
      - importlib-resources==5.4.0
      - iniconfig==1.1.1
      - jsonschema==3.2.0
      - logilab-common==1.9.7
      - mccabe==0.7.0
      - mock==5.2.0
      - mypy-extensions==1.0.0
      - nodeenv==1.6.0
      - ordereddict==1.1
      - packaging==21.3
      - platformdirs==2.4.0
      - pluggy==1.0.0
      - py==1.11.0
      - pycodestyle==2.9.1
      - pyflakes==2.5.0
      - pylint==1.3.1
      - pyparsing==3.1.4
      - pyrsistent==0.18.0
      - pytest==7.0.1
      - pyyaml==6.0.1
      - simplejson==3.20.1
      - six==1.17.0
      - tomli==1.2.3
      - typing-extensions==4.1.1
      - virtualenv==20.17.1
      - zipp==3.6.0
prefix: /opt/conda/envs/pre-commit

tests/commands/install_uninstall_test.py::test_install_hooks_directory_not_present
tests/commands/install_uninstall_test.py::test_install_pre_commit_and_run tests/commands/install_uninstall_test.py::test_install_idempotent tests/commands/install_uninstall_test.py::test_environment_not_sourced tests/commands/install_uninstall_test.py::test_failing_hooks_returns_nonzero tests/commands/install_uninstall_test.py::test_install_existing_hooks_no_overwrite tests/commands/install_uninstall_test.py::test_install_existing_hook_no_overwrite_idempotent tests/commands/install_uninstall_test.py::test_failing_existing_hook_returns_1 tests/commands/install_uninstall_test.py::test_install_overwrite_no_existing_hooks tests/commands/install_uninstall_test.py::test_install_overwrite tests/commands/install_uninstall_test.py::test_uninstall_restores_legacy_hooks tests/commands/install_uninstall_test.py::test_replace_old_commit_script tests/commands/install_uninstall_test.py::test_installs_hooks_with_hooks_True tests/commands/install_uninstall_test.py::test_installed_from_venv tests/commands/install_uninstall_test.py::test_pre_push_integration_failing tests/commands/install_uninstall_test.py::test_pre_push_integration_accepted
tests/commands/install_uninstall_test.py::test_is_not_our_pre_commit tests/commands/install_uninstall_test.py::test_is_our_pre_commit tests/commands/install_uninstall_test.py::test_is_not_previous_pre_commit tests/commands/install_uninstall_test.py::test_is_also_not_previous_pre_commit tests/commands/install_uninstall_test.py::test_is_previous_pre_commit tests/commands/install_uninstall_test.py::test_install_pre_commit tests/commands/install_uninstall_test.py::test_uninstall_does_not_blow_up_when_not_there tests/commands/install_uninstall_test.py::test_uninstall tests/commands/install_uninstall_test.py::test_uninstall_doesnt_remove_not_our_hooks
pre_commit/commands/install_uninstall.py
pre_commit/commands/install_uninstall.py