Study notes · 10% of the exam

Remotes, Fetch, Pull, Push and Tags

Remotes are named URLs, and remote-tracking branches like origin/main are your local cache of where the remote's branches were at your last fetch. Fetch downloads, pull integrates, push uploads, and tags travel only when you ask.

Key points

  1. 1

    git fetch updates origin/* refs only; your branches, index and files never change. git pull is fetch plus merge (or rebase).

  2. 2

    Remote-tracking refs change only on fetch, pull or push, so git status ahead/behind counts are as stale as your last fetch.

  3. 3

    A push must be a fast-forward of the remote branch; "rejected (fetch first)" means someone pushed first, so fetch and integrate before pushing again.

  4. 4

    With push.default = simple, a branch without an upstream needs git push -u origin <branch>, or set push.autoSetupRemote = true.

  5. 5

    Tags are not pushed by default: use git push origin <tag>, --follow-tags (annotated, reachable) or --tags (all). git describe uses annotated tags unless you pass --tags.

  6. 6

    Deleted remote branches linger locally until git fetch --prune; tags need --prune-tags.

  7. 7

    --depth implies --single-branch; partial clones (--filter=blob:none) keep full history and fetch file contents on demand.

Common traps

  • A plain git fetch never moves a tag you already have; moving a published tag silently leaves teammates on the old commit.

  • On Windows, Git for Windows' system config sets pull.rebase = false, so git pull merges where a clean Linux Git would stop and ask.

  • Fork pull requests don't get repository secrets in pull_request workflows, and GITHUB_TOKEN is read-only.

Test yourself on Remotes, Fetch, Pull, Push and Tags

Ten questions, with the answer and explanation after each one.