diff --git a/pre_commit/resources/hook-tmpl b/pre_commit/resources/hook-tmpl
index 2a9657e..d357585 100755
--- a/pre_commit/resources/hook-tmpl
+++ b/pre_commit/resources/hook-tmpl
@@ -105,6 +105,10 @@ def _exe():
     )
 
 
+def _rev_exists(rev):
+    return not subprocess.call(('git', 'rev-list', '--quiet', rev))
+
+
 def _pre_push(stdin):
     remote = sys.argv[1]
 
@@ -113,7 +117,7 @@ def _pre_push(stdin):
         _, local_sha, _, remote_sha = line.split()
         if local_sha == Z40:
             continue
-        elif remote_sha != Z40:
+        elif remote_sha != Z40 and _rev_exists(remote_sha):
             opts = ('--origin', local_sha, '--source', remote_sha)
         else:
             # First ancestor not found in remote

Invalid symmetric difference expression
```
$ git push
An unexpected error has occurred: CalledProcessError: Command: ('/nix/store/4c12r17gwha2hh6gvc6y2i0s6ckjc09y-git-2.16.2/libexec/git-core/git', 'diff', '--name-only', '--no-ext-diff', '-z', '192a93890ea5100a22a42a73249f7c1e571ebb0b...857ce8997c4f431c06ec52ef0ba1a64983ae945f')
Return code: 128
Expected return code: 0
Output: (none)
Errors:
    fatal: Invalid symmetric difference expression 192a93890ea5100a22a42a73249f7c1e571ebb0b...857ce8997c4f431c06ec52ef0ba1a64983ae945f


Check the log at /home/ielectric/.cache/pre-commit/pre-commit.log
```

I understand this happens if one rewrites git history, but pre-commit shouldn't fail in that case.
diff --git a/tests/commands/install_uninstall_test.py b/tests/commands/install_uninstall_test.py
index 9f80569..6aa9c7f 100644
--- a/tests/commands/install_uninstall_test.py
+++ b/tests/commands/install_uninstall_test.py
@@ -495,13 +495,13 @@ def test_installed_from_venv(tempdir_factory, store):
         assert NORMAL_PRE_COMMIT_RUN.match(output)
 
 
-def _get_push_output(tempdir_factory):
+def _get_push_output(tempdir_factory, opts=()):
     return cmd_output_mocked_pre_commit_home(
-        'git', 'push', 'origin', 'HEAD:new_branch',
+        'git', 'push', 'origin', 'HEAD:new_branch', *opts,
         # git push puts pre-commit to stderr
         stderr=subprocess.STDOUT,
         tempdir_factory=tempdir_factory,
-        retcode=None,
+        retcode=None
     )[:2]
 
 
@@ -535,6 +535,26 @@ def test_pre_push_integration_accepted(tempdir_factory, store):
         assert 'Passed' in output
 
 
+def test_pre_push_force_push_without_fetch(tempdir_factory, store):
+    upstream = make_consuming_repo(tempdir_factory, 'script_hooks_repo')
+    path1 = tempdir_factory.get()
+    path2 = tempdir_factory.get()
+    cmd_output('git', 'clone', upstream, path1)
+    cmd_output('git', 'clone', upstream, path2)
+    with cwd(path1):
+        assert _get_commit_output(tempdir_factory)[0] == 0
+        assert _get_push_output(tempdir_factory)[0] == 0
+
+    with cwd(path2):
+        install(Runner(path2, C.CONFIG_FILE), store, hook_type='pre-push')
+        assert _get_commit_output(tempdir_factory, commit_msg='force!')[0] == 0
+
+        retc, output = _get_push_output(tempdir_factory, opts=('--force',))
+        assert retc == 0
+        assert 'Bash hook' in output
+        assert 'Passed' in output
+
+
 def test_pre_push_new_upstream(tempdir_factory, store):
     upstream = make_consuming_repo(tempdir_factory, 'script_hooks_repo')
     upstream2 = git_dir(tempdir_factory)

pip install -e .[dev]
parse_log_pytest
requirements.txt
coverage pytest pytest-env
apt-get update apt-get install -y gcc
3.6
requirements-dev.txt
pytest --no-header -rA --tb=line --color=no -p no:cacheprovider -W ignore::DeprecationWarning
aspy.yaml==1.3.0
attrs==22.2.0
cached-property==1.5.2
certifi==2021.5.30
cfgv==3.3.1
coverage==6.2
distlib==0.3.9
filelock==3.4.1
flake8==5.0.4
identify==2.4.4
importlib-metadata==4.8.3
importlib-resources==5.4.0
iniconfig==1.1.1
mccabe==0.7.0
mock==5.2.0
nodeenv==1.6.0
packaging==21.3
platformdirs==2.4.0
pluggy==1.0.0
-e git+https://github.com/pre-commit/pre-commit.git@13c85f374b389447bfe0a6d1e9109f9cc30724ea#egg=pre_commit
py==1.11.0
pycodestyle==2.9.1
pyflakes==2.5.0
pyparsing==3.1.4
pytest==7.0.1
pytest-env==0.6.2
PyYAML==6.0.1
six==1.17.0
toml==0.10.2
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:
      - aspy-yaml==1.3.0
      - attrs==22.2.0
      - cached-property==1.5.2
      - cfgv==3.3.1
      - coverage==6.2
      - distlib==0.3.9
      - filelock==3.4.1
      - flake8==5.0.4
      - identify==2.4.4
      - importlib-metadata==4.8.3
      - importlib-resources==5.4.0
      - iniconfig==1.1.1
      - mccabe==0.7.0
      - mock==5.2.0
      - nodeenv==1.6.0
      - packaging==21.3
      - platformdirs==2.4.0
      - pluggy==1.0.0
      - py==1.11.0
      - pycodestyle==2.9.1
      - pyflakes==2.5.0
      - pyparsing==3.1.4
      - pytest==7.0.1
      - pytest-env==0.6.2
      - pyyaml==6.0.1
      - six==1.17.0
      - toml==0.10.2
      - 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_pre_push_force_push_without_fetch
tests/commands/install_uninstall_test.py::test_install_in_submodule_and_run tests/commands/install_uninstall_test.py::test_environment_not_sourced
tests/commands/install_uninstall_test.py::test_is_not_script tests/commands/install_uninstall_test.py::test_is_script 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_install_hooks_directory_not_present tests/commands/install_uninstall_test.py::test_install_refuses_core_hookspath tests/commands/install_uninstall_test.py::test_install_hooks_dead_symlink 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_install_pre_commit_and_run tests/commands/install_uninstall_test.py::test_install_pre_commit_and_run_custom_path tests/commands/install_uninstall_test.py::test_commit_am tests/commands/install_uninstall_test.py::test_unicode_merge_commit_message tests/commands/install_uninstall_test.py::test_install_idempotent 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_uninstall_doesnt_remove_not_our_hooks tests/commands/install_uninstall_test.py::test_installs_hooks_with_hooks_True tests/commands/install_uninstall_test.py::test_install_hooks_command 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_pre_push_new_upstream tests/commands/install_uninstall_test.py::test_pre_push_integration_empty_push tests/commands/install_uninstall_test.py::test_pre_push_legacy tests/commands/install_uninstall_test.py::test_commit_msg_integration_failing tests/commands/install_uninstall_test.py::test_commit_msg_integration_passing tests/commands/install_uninstall_test.py::test_commit_msg_legacy tests/commands/install_uninstall_test.py::test_install_disallow_mising_config tests/commands/install_uninstall_test.py::test_install_allow_mising_config tests/commands/install_uninstall_test.py::test_install_temporarily_allow_mising_config
pre_commit/resources/hook-tmpl
pre_commit/resources/hook-tmpl