Distributed Version Control: How Git Works Offline
Local, centralized and distributed history
A local-only version control tool keeps history on one machine. A centralized system commonly relies on a central repository for recording shared history; exact offline abilities vary by tool. Git is distributed: repositories can keep their own history and create commits independently. A team can still agree to use a central shared repository, such as one on GitHub, as a coordination point.
Example: two people work separately
A clone is a new repository created from an existing one. Imagine Ali and Sara each start with checkpoint A. Ali commits B while offline; Sara commits C in her own clone. The arrows below point from a commit to its parent. When both reconnect, their changes can be exchanged and integrated using Git, sometimes requiring conflict resolution. Nothing moves to the shared copy just because a local commit was created.
Preview: inspect an independent clone
The Chapter 1 lab setup creates two local copies, notes and partner. Both initially share the same three recorded checkpoints; the setup then creates one extra commit in partner. In the partner directory, the following command lists commit messages, newest first, in the linear lab history. git log reads history; --format=%s shows only the message subject. The command is a preview, not a prerequisite for understanding distribution. See lab-fixtures/chapter1-guide.md in the downloadable package for setup and cleanup.
Expected result
The first line belongs only to the partner copy at this point. The other three belong to both copies. Running the same command in notes lists only the last three lines; it has not received the partner commit.
Why a clone is not a complete backup
A normal full clone obtains project history available through the selected remote references, but it does not copy uncommitted edits, untracked files, all local settings or every private reference. Shallow and partial clones can have additional history or object limitations. In the lab, the uncommitted Bread edit in notes is absent from partner. Keep backups for important data beyond the committed project history.
Practice and next steps
Imagine you commit a change while offline and then lose the only device containing that new commit. A teammate has yesterday’s clone. Explain which recorded work they can recover and which new work they cannot. Then explain why sharing commits and making independent backups solve different problems. You are now ready to install Git and create your own first repository in Chapter 2.
Check Your Understanding
Solidify your learning with the interactive assessment directly below this lesson.
Concept Quiz & Questions
Distributed Version Control: How Git Works Offline — knowledge check
Check your understanding of the lesson through practical scenarios.
Ali and Sara commit independently in their clones. Must a shared server be reachable for each local commit?
What is the first message in the partner lab history?
Which item is not copied by an ordinary clone from the source working tree?
Can a distributed team choose one central shared repository?
A laptop with an unshared new commit is lost. Yesterday’s clone survives. What can that clone provide?