Skip to content

Commitizen-branch with pre-commit prevents from push to origin with exit code 23 #704

Description

@vabatta

Description

Whenever I try to push a commit to the origin (git push -u origin main), an error is preventing me from pushing:

commitizen check branch..................................................Failed
- hook id: commitizen-branch
- exit code: 23

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>...]'


error: failed to push some refs to 'https://github.com/<some repo>.git'

Steps to reproduce

  1. Run cz init.
  2. Run pre-commit install --hook-type commit-msg --hook-type pre-push
  3. Run git init && git add . && git commit -m "feat: my new commit"
  4. Run git remote add origin https://github.com/<some repo>.git
  5. Run git push -u origin main

Current behavior

I should be able to push it correctly to origin.

Desired behavior

I want to push it to origin.

Screenshots

No response

Environment

Commitizen Version: 2.42.1
Python Version: 3.9.2 (default, Feb 28 2021, 17:03:44) 
[GCC 10.2.1 20210110]
Operating System: Linux

Activity

  1. Corfucinas commented on Jun 19, 2023

    @Corfucinas

    I have exactly the same bug

    image

  2. vabatta commented on Jun 19, 2023

    @vabatta
    Author

    If you are using dev containers, for me it worked by cleaning my local dev container and let it rebuild.

  3. Corfucinas commented on Jun 23, 2023

    @Corfucinas

    Any quick solution to this bug? (that is not --no-verify)

  4. eadgbear commented on Aug 15, 2023

    @eadgbear
    Contributor

    I'm still seeing this as well. I added cz to an existing repo, but in a new branch that did not exist on origin yet, if that helps.

  5. eadgbear commented on Aug 17, 2023

    @eadgbear
    Contributor

    For anyone still running into this, here's how you fix it:

    git remote set-head origin --auto

    For whatever reason, HEAD was not set in my repo.

    Before:

    $ git branch -a
    * dev/initial_structure
      main
      remotes/origin/dev/initial_structure
      remotes/origin/main

    After:

    $ git branch -a
    * dev/initial_structure
      main
      remotes/origin/HEAD -> origin/main
      remotes/origin/dev/initial_structure
      remotes/origin/main
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions