Skip to content

Stray main tag makes git pull origin main a silent no-op (tag shadows branch) #213

Closed

Description

Summary

refs/tags/main (lightweight, → 0b3b528, #44) coexists with refs/heads/main. Git resolves an unqualified refspec by matching refs/tags/<name> before refs/heads/<name> (count_refspec_match() in remote.c), so the very common

git pull origin main

fetches the tag instead of the branch, then merges/rebases onto the tag's old commit. The command still exits 0, so the failure is silent: the checkout never updates.

Reproduction (against 0be7a76)

$ git fetch --dry-run origin main
 * tag               main       -> FETCH_HEAD        # expected: branch

$ git pull --rebase origin main
 * tag               main       -> FETCH_HEAD
Already up to date.                                   # exit 0, branch unchanged

A fully qualified refspec behaves correctly:

$ git fetch --dry-run origin refs/heads/main
 * branch            main       -> FETCH_HEAD

Impact

Every client that passes the short branch name to git pull — GUI clients such as UGit do exactly git pull --recurse-submodules origin main, and so do many scripts — silently stops receiving updates. Worse, with pull.rebase=true the local branch can be moved backwards to 0b3b528: rebasing onto an ancestor of HEAD is reported as "already up to date", so the commits above it are dropped from the branch.

We hit precisely this: local main was rewound one commit, and three consecutive pull attempts returned success without applying the ~105 upstream commits. git fetch without a refspec was equally stale, because the branch half of the pull never ran.

git pull with no arguments is unaffected (it resolves branch.<name>.merge rather than matching a remote ref by name), which makes the problem easy to misdiagnose.

Suggested fix

Delete the stray tag — every other tag in this repository follows v*, so main looks accidental:

git push origin :refs/tags/main

(or Releases → Tags → main → Delete in the GitHub UI).

Workaround for affected clients until then

git pull --rebase origin refs/heads/main

Reproduced with git 2.45.2.windows.1 on Windows.

Activity

  1. added a commit that references this issue on Oct 22, 2026
    d25ade6
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions