You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Runcz check --range origin/master..HEAD to check commits in CI occasionally fails.
And it worked after I retried the job.But sometimes it didn't work after retrying multiple times.
I couldn't find out the reason ,
fatal: ambiguous argument 'master..HEAD': unknown revision or path not in the working tree.
Use '--' to separate paths from revisions, like this:
'git <command> [<revision>...] -- [<file>...]'
Desired behavior
cz check --rev-range can run successfully in gitlab CI.
Screenshots
Environment
commitizen version: 2.34.0
python version: 3.7.5
operating system: Linux
What would be the output of git log origin/master..? Can it generate output as expected?
Oh,it didn't show anything of git log origin/master. Maybe there's no git fetch on some CI machines. I try git fetch origin and it works. Thanks for your help!
Hi, I am having the same issue outside of CI. When I git push with the pre-push pre-commit hook, I get the following:
fatal: ambiguous argument 'origin/HEAD..HEAD': unknown revision or path not in the working tree.
Use '--' to separate paths from revisions, like this:
'git <command> [<revision>...] -- [<file>...]'
Whereas if I skip the verification everything works fine.
Unfortunately the repo is private and I can't share the url, but the configs are:
Hi, I am having the same issue outside of CI. When I git push with the pre-push pre-commit hook, I get the following:
fatal: ambiguous argument 'origin/HEAD..HEAD': unknown revision or path not in the working tree.
Use '--' to separate paths from revisions, like this:
'git <command> [<revision>...] -- [<file>...]'
Whereas if I skip the verification everything works fine.
Unfortunately the repo is private and I can't share the url, but the configs are:
Hello, if I run cz check --rev-range origin/main..HEAD it works. I noticed that the pre-commit hook has --rev-range origin/HEAD..HEAD which is an invalid ref. Perhaps when the repo has multiple branches the reference becomes invalid? Will try to make a reprex soon.
Reacted by Santiago Fraire Willemoes, Charles Aracil, golegario96 and Daniel Black
Checking older or related issues to access the tool's status.
Access master branch on GitLab CI : Only the current branch commits are accessible + shallow history, fetching is needed for any branch
Settings / CI/CD / Git shallow clone:The number of changes to fetch from GitLab when cloning a repository. Lower values can speed up pipeline execution. Set to 0 or blank to fetch all branches and tags for each job (default: 50)
Comparing with another branch or even using the current branch or the merge request target branch needs fetching
Variables : By default, the *_SHA variables are the ones for detecting the commit's / pipeline's context
Triage from #1964: This is caused by GitLab CI's shallow clone — origin/master isn't present in the runner's local refs — not a commitizen bug. Workaround: set GIT_DEPTH: 0 in your .gitlab-ci.yml (or git fetch --unshallow / git fetch origin master:master before running cz check --rev-range). Suggesting we close this.
git fetch origin master:refs/remotes/origin/master — fixes origin/master..HEAD without unshallowing
Verdict: NOT A BUG / CI ENVIRONMENT.
The failure is purely a GitLab-CI shallow-clone artifact: origin/master isn't a fetched ref in the runner's local repo. Commitizen passes the rev-range to git log, which errors as expected.
Workaround for the user's GitLab pipeline:
variables:
GIT_DEPTH: "0"# or sufficient depth to include the merge base# orscript:
- git fetch origin master:refs/remotes/origin/master
- cz check --rev-range origin/master..HEAD
Closing-eligible.
(One improvement we could make in commitizen itself: catch the git log error in cz check --rev-range and surface a clearer message like "Could not resolve rev-range '<range>': did you forget to fetch the base branch in CI?". Optional.)
Closing as not a bug: reproduced as a CI shallow-clone artifact. Workarounds (GIT_DEPTH: 0 or git fetch origin master:refs/remotes/origin/master) confirmed working. See verification comment above.
Activity
SsuperL commentedon Dec 1, 2022
yes.
Lee-W commentedon Dec 3, 2022
What would be the output of
git log origin/master..? Can it generate output as expected?SsuperL commentedon Dec 5, 2022
Oh,it didn't show anything of
git log origin/master. Maybe there's nogit fetchon some CI machines. I trygit fetch originand it works. Thanks for your help!Lee-W commentedon Dec 19, 2022
@SsuperL One of the stuff I can think of is shallow clone. Maybe you could take a look at this direction as well :)
SsuperL commentedon Dec 20, 2022
Okay, I'll check it out.
baggiponte commentedon Mar 22, 2023
Hi, I am having the same issue outside of CI. When I
git pushwith thepre-pushpre-commit hook, I get the following:Whereas if I skip the verification everything works fine.
Unfortunately the repo is private and I can't share the url, but the configs are:
And the hook (which should not matter) is:
SsuperL commentedon Mar 23, 2023
Have you tried
git fetch? That works for me.baggiponte commentedon Mar 23, 2023
Does not for me... Perhaps it can mess up if I have
git push --forcepreviously?baggiponte commentedon Mar 27, 2023
Hello, if I run
cz check --rev-range origin/main..HEADit works. I noticed that the pre-commit hook has--rev-range origin/HEAD..HEADwhich is an invalid ref. Perhaps when the repo has multiple branches the reference becomes invalid? Will try to make a reprex soon.build(vcs): Workaround commitizen push hook bug
johanmynhardt commentedon Dec 21, 2023
The following fixed it for me:
Eventually found a semi-good explanation at: https://learnku.com/articles/71493
(My issue is actually when I'm trying to run
git pushwith the pre-push hook enabled, which then gives a similar error on ambiguity.)AdrianDC commentedon Aug 19, 2024
Checking older or related issues to access the tool's status.
Access
masterbranch on GitLab CI : Only the current branch commits are accessible + shallow history, fetching is needed for any branchThe number of changes to fetch from GitLab when cloning a repository. Lower values can speed up pipeline execution. Set to 0 or blank to fetch all branches and tags for each job(default: 50)*_SHAvariables are the ones for detecting the commit's / pipeline's contextThe
CI_COMMIT_BEFORE_SHAvariable can be used to compare a CI with the previously pushed commit, but handlings are needed:000..in specific cases, and might be unknown if the commit was amended and force-pushedorigin/HEAD..HEADpush issues : fix(pre-commit-hooks)!: allow empty ranges in 'commitizen-branch' #1209dboeckenhoff commentedon Jan 14, 2025
Having the same issue as new user in 2025; git fetch did not help
Lee-W commentedon Mar 30, 2025
Hey could you please provide an example so that we could try to reproduce and see what's happening? Thanks!
bearomorphism commentedon May 9, 2026
Triage from #1964: This is caused by GitLab CI's shallow clone —
origin/masterisn't present in the runner's local refs — not a commitizen bug. Workaround: setGIT_DEPTH: 0in your.gitlab-ci.yml(orgit fetch --unshallow/git fetch origin master:masterbefore runningcz check --rev-range). Suggesting we close this.bearomorphism commentedon May 9, 2026
Verification update (re #1964)
Reproduced against current master (4.15.1):
git clone --depth=1of the default branch —cz check --rev-range origin/master..HEADworks fine (origin/masteris present).masterrefs) reproduces the exact failure:git fetch --unshallow origin master:master— fixesmaster..HEADgit fetch origin master:refs/remotes/origin/master— fixesorigin/master..HEADwithout unshallowingVerdict: NOT A BUG / CI ENVIRONMENT.
The failure is purely a GitLab-CI shallow-clone artifact:
origin/masterisn't a fetched ref in the runner's local repo. Commitizen passes the rev-range togit log, which errors as expected.Workaround for the user's GitLab pipeline:
Closing-eligible.
(One improvement we could make in commitizen itself: catch the
git logerror incz check --rev-rangeand surface a clearer message like"Could not resolve rev-range '<range>': did you forget to fetch the base branch in CI?". Optional.)bearomorphism commentedon May 9, 2026
Closing as not a bug: reproduced as a CI shallow-clone artifact. Workarounds (
GIT_DEPTH: 0orgit fetch origin master:refs/remotes/origin/master) confirmed working. See verification comment above.