git fetch origin master:master does not advance origin/master, but it does advance FETCH_HEAD

Unexpected Behavior Analysis: git fetch origin master:master Does Not Update origin/master

Summary

  • Executing git fetch origin master:master failed to update origin/master despite fetching new commits
  • The operation showed ! [rejected] master -> master (non-fast-forward) and created new tags
  • FETCH_HEAD was successfully updated with the latest commit
  • Running git fetch origin master later updated origin/master as expected
  • No recent Git version change or configuration issues were detected

Root Cause

  • The refspec master:master explicitly targets the local branch named master (not origin/master)
  • The command attempted an unsafe (non-fast-forward) update to the local master branch, which did not have a direct lineage to the new commit (non-fast-forward rejection)
  • FETCH_HEAD always updates during fetch operations per Git’s design
  • origin/master only updates when:
    • Using git fetch origin (updates all tracking refs)
    • Or explicitly fetching to the tracking ref (git fetch origin master)

Why This Happens in Real Systems

  • Refspec misunderstandings are common due to Git’s dual ref concepts:
    • Remote-tracking refs (origin/master)
    • Local branches (master)
  • Production scripts often contain explicit refspecs for “efficiency”
  • Team members may run commands inconsistently (“fetch to local branch” vs “fetch to tracking ref”)
  • Infrastructure changes can cause unexpected commit histories (force-pushes, rebases)

Real-World Impact

  • Developers get inconsistent repository states
  • Build systems may