Skip to content

fix(github): disambiguate contributors workflow push refspec#1137

Merged
muddlebee merged 1 commit intomainfrom
fix/contributors-push-ambiguous-ref
Apr 30, 2026
Merged

fix(github): disambiguate contributors workflow push refspec#1137
muddlebee merged 1 commit intomainfrom
fix/contributors-push-ambiguous-ref

Conversation

@muddlebee
Copy link
Copy Markdown
Collaborator

Problem

The Update Contributors workflow fails on push with:

error: dst refspec main matches more than one

This happens when both refs/heads/main and refs/tags/main exist; HEAD:main is ambiguous.

Change

Use explicit branch refs for pull/rebase and push:

  • git pull --rebase origin "refs/heads/${GITHUB_REF_NAME}"
  • git push origin "HEAD:refs/heads/${GITHUB_REF_NAME}"

- Use refs/heads/ for pull and push so tag named main cannot collide with branch main
@muddlebee muddlebee merged commit ffadafe into main Apr 30, 2026
7 checks passed
@muddlebee muddlebee deleted the fix/contributors-push-ambiguous-ref branch April 30, 2026 11:28
@github-actions
Copy link
Copy Markdown
Contributor

🏆 @muddlebee did not come to play. PR opened. Review survived. Merged clean. Retire the jersey. 🎽


👋 Join us on Discord - OpenSRE : hang out, contribute, or hunt for features and issues. Everyone's welcome.

@greptile-apps
Copy link
Copy Markdown
Contributor

greptile-apps Bot commented Apr 30, 2026

Greptile Summary

This PR fixes the dst refspec main matches more than one push failure in the Update Contributors workflow by replacing the ambiguous HEAD:${GITHUB_REF_NAME} refspec with the explicit HEAD:refs/heads/${GITHUB_REF_NAME} for both the git pull --rebase and git push commands. The fix is targeted and correct — it eliminates the ambiguity that arises when a tag named main coexists with the main branch.

Confidence Score: 5/5

Safe to merge — the change is a minimal, correct fix with no regressions.

Both changed lines correctly apply the refs/heads/ prefix, directly resolving the documented ambiguity. No logic is altered, no new risk is introduced, and the fix matches Git's documented behaviour for disambiguating branch vs. tag refspecs.

No files require special attention.

Important Files Changed

Filename Overview
.github/workflows/contributors.yml Disambiguates git pull/push refspecs by using explicit refs/heads/ prefix, fixing the "dst refspec matches more than one" error when a tag shares the branch name.

Sequence Diagram

sequenceDiagram
    participant W as Workflow Runner
    participant L as Local Git
    participant R as origin (GitHub)

    W->>L: git add README.md
    W->>L: git diff --staged --quiet || git commit
    Note over W,L: Only commits if README changed

    alt HEAD has a parent commit
        W->>R: git pull --rebase origin refs/heads/${GITHUB_REF_NAME}
        Note over W,R: Explicit refs/heads/ avoids tag ambiguity
        R-->>L: rebased remote changes
    end

    W->>R: git push origin HEAD:refs/heads/${GITHUB_REF_NAME}
    Note over W,R: Explicit refs/heads/ avoids matches more than one error
Loading

Reviews (1): Last reviewed commit: "fix(github): disambiguate contributors w..." | Re-trigger Greptile

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant