Skip to content
rajin

24Upstream branches and refspecs

intermediate25–30 minHandbook pp. 53–54 Not started

Warm-up · from “Fetch, pull and push”

What does fetch update in a normal clone?

No notes: write what you remember, then check. Recalling before reading is what makes it stick.

The problem

Your local branch is named experiment, but the team wants it published as team-demo. Git can map different names.

After this lesson you can

  • Read fetch and push refspecs.

  • Set upstream tracking.

  • Distinguish remote and local namespaces.

Key terms

Full glossary

Say what each term means, then open it to check.

  • Refspec · new in this lesson

    Source-to-destination mapping for references.

  • Remote-tracking ref · from lesson 22

    Local record of a remote branch state, updated by configured operations.

  • Ref · from lesson 3

    Name identifying an object; branch refs usually identify commits.

Visual mental model

  1. Remote refs/heads/main
  2. fetch map
  3. local refs/remotes/origin/main

Build the mental model

A refspec maps a source ref to a destination ref, typically SRC:DST. Fetch mappings identify remote sources and local destinations; push mappings identify local sources and remote destinations. A default clone fetch rule is +refs/heads/*:refs/remotes/origin/*, meaning remote branch refs map into local origin tracking refs. The leading plus permits non-fast-forward updates of that tracking namespace.

SimulationRefspecs map names

A simplified model for building intuition. It does not read your sandbox; use the terminal for real behaviour.

Under the hood

An upstream is configuration connecting a local branch to a remote and a branch name for status and integration. git push -u origin main establishes tracking for a matching branch; git branch --set-upstream-to=origin/team-demo can configure a different name. The default simple push mode may refuse if local and upstream names differ, so use explicit refspecs when intentional.

Common mistake · important nuance

Remote-tracking refs are local refs maintained by normal fetch/push operations; they are not inherently immutable or physically read-only.

Move between parts freely. Completion counts only what you verify and answer.