Skip to content

dst refspec main matches more than one when remote has a main branch and a main tag #8572

@arunsathiya

Description

@arunsathiya

Describe the bug

gh pr create fails with error: dst refspec main matches more than one when local and remote repositories have a branch and a tag with the same name. git push --set-upstream origin main succeeds in the same scenario, indicating a potential issue in how gh handles refspecs. gh version: [insert your gh version here].

Steps to reproduce the behavior

  1. In a local repo, have a branch and a tag named main.
  2. Ensure the remote (GitHub) repo also has a branch and a tag named main.
  3. Try creating a PR with gh pr create --title "Example" -F example.txt. (to an upstream remote, but for this bug report, it doesn't matter if the upstream has the same main branch and main tag conflict)
  4. Observe the error: error: dst refspec main matches more than one.

Expected vs actual behavior

Expected: gh pr create should handle the branch and tag naming conflict as gracefully as git push, creating the PR without errors.

Actual: The command fails with error: dst refspec main matches more than one.

Logs

Failure:

gh pr create --title "ci: Use GITHUB_OUTPUT envvar instead of set-output command" -F ~/Downloads/prbody.txt
? Where should we push the 'main' branch? Create a fork of microsoft/azure-schema-operator

Creating pull request for arunsathiya:main into main in microsoft/azure-schema-operator

error: dst refspec main matches more than one
error: failed to push some refs to 'github.com:arunsathiya/azure-schema-operator.git'
waiting 2 seconds before retrying...
error: dst refspec main matches more than one
error: failed to push some refs to 'github.com:arunsathiya/azure-schema-operator.git'
waiting 2 seconds before retrying...
error: dst refspec main matches more than one
error: failed to push some refs to 'github.com:arunsathiya/azure-schema-operator.git'
waiting 2 seconds before retrying...
error: dst refspec main matches more than one
error: failed to push some refs to 'github.com:arunsathiya/azure-schema-operator.git'
waiting 2 seconds before retrying...
failed to run git: exit status 1

What worked:

git push --set-upstream origin main
Enumerating objects: 9, done.
Counting objects: 100% (9/9), done.
Delta compression using up to 8 threads
Compressing objects: 100% (5/5), done.
Writing objects: 100% (5/5), 674 bytes | 674.00 KiB/s, done.
Total 5 (delta 4), reused 0 (delta 0), pack-reused 0
remote: Resolving deltas: 100% (4/4), completed with 4 local objects.
To github.com:arunsathiya/azure-schema-operator.git
   6b65409..8a98674  main -> main
branch 'main' set up to track 'origin/main'.


gh pr create --title "ci: Use GITHUB_OUTPUT envvar instead of set-output command" -F ~/Downloads/prbody.txt

Creating pull request for arunsathiya:main into main in microsoft/azure-schema-operator

https://github.com/microsoft/azure-schema-operator/pull/26

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workinggh-prrelating to the gh pr commandhelp wantedContributions welcomep3Affects a small number of users or is largely cosmetic

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions