Hacktoberfest 2026: le issue che i maintainer hanno segnato per ottobre, aperte e adatte ai principianti. Sfoglia le issue Hacktoberfest

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

Aperta Adatta ai principianti
#213 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
1/5
Tempo stimato
Meno di un'ora
Idoneità per principianti
65/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
git, rust
Ambito
release

Direzione di ricerca

L’issue identifica il tag main creato per errore e indica il comando proposto per eliminarlo git push origin :refs/tags/main. Controlla l’elenco dei tag del repository e conferma che il tag main sia quello descritto, quindi rimuovilo. Verifica che git fetch --dry-run origin main faccia riferimento al branch in seguito.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

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.

Lingua principale
Rust
Stelle
3.5k
Fork
140
Merge medio
15h 32m
PR unite (30g)
27

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di microsoft/tgrep

Tutte le issue di microsoft/tgrep

Issue simili

Altre issue su Rust

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.