Skip to content
rajin

22Cloning and remote repositories

intermediate25–30 minHandbook pp. 49–50 Not started

Warm-up · from “Reset, revert and amend”

Which reset mode preserves both Index and working tree?

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

The problem

You want a teammate to start contributing without sending a ZIP archive. What does cloning actually transfer?

After this lesson you can

  • Explain clone and bare repositories.

  • Identify origin.

  • Distinguish local branches from remote-tracking refs.

Key terms

Full glossary

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

  • Remote-tracking ref · new in this lesson

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

  • Commit · from lesson 7

    Object identifying a root tree, parent(s), metadata and message.

  • Tree · from lesson 6

    Directory snapshot mapping names, modes and object IDs.

  • Ref · from lesson 3

    Name identifying an object; branch refs usually identify commits.

Visual mental model

  1. Local repo A
  2. Bare shared repo
  3. Clone B

Build the mental model

A normal clone creates a repository, obtains objects and refs from a source, configures a remote usually named origin, and checks out an initial branch when possible. Every ordinary clone has its own local object database and can commit offline. Shallow clones and partial clones are important exceptions to the idea that every clone contains all history or all objects.

SimulationTwo repositories and a bare server

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

Under the hood

A bare repository has repository metadata without a normal checked-out working tree. It is useful as a local simulation of a shared server. Remote names are local aliases for URLs and configuration; origin is a convention, not a special server. Remote-tracking refs such as origin/main are local records of observed remote state, not live network pointers.

Common mistake · important nuance

Git and a hosting service are separate. A remote URL can be a local directory, HTTPS URL or SSH location.

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