Description
After installing both commitizen hooks, I get the following error message when pushing my changes:
commitizen check branch..................................................Failed
- hook id: commitizen-branch
- exit code: 23
fatal: ambiguous argument '$PRE_COMMIT_FROM_REF..$PRE_COMMIT_TO_REF': unknown revision or path not in the working tree.
Use '--' to separate paths from revisions, like this:
'git <command> [<revision>...] -- [<file>...]'
Steps to reproduce
- Create repo
- Install pre-commit hooks
pre-commit install -t pre-commit -t commit-msg -t pre-push
- Push to
origin
Current behavior
At first I thought this was because this was a brand new repo, so I pushed with --no-verify, but on my first PR I got the same error.
My best guess is that while pre-commit does use those environment variables, they are only set when from_ref and to_ref are set. See here.
But what is set on your .pre-commit-hooks.yaml file, is a reference to an environment variable that is not set.
You are using args: [--rev-range, "$PRE_COMMIT_FROM_REF..$PRE_COMMIT_TO_REF"], but those variables are yet to be set.
If I use args: [--rev-range, "origin/main..HEAD"] on my .pre-commit-config.yaml file, it works.
But as it is right now it fails.
Desired behavior
This should succeed.
Screenshots
No response
Environment
Commitizen Version: 4.13.9
Python Version: 3.14.3 (main, Feb 3 2026, 22:53:56) [MSC v.1944 64 bit (AMD64)]
Operating System: Windows