Chapter 01Lesson 01~70 minutes

Version Control Foundations and Distributed Collaboration: Concepts, Architecture, and Mental Model

Build a durable mental model of why version control exists, how Git represents change as connected snapshots, and what distributed collaboration means before learning command-heavy workflows.

FoundationsDistributed GitSnapshotsMental model

Learning objectives

  • Explain the problems version control solves beyond “keeping old copies” and connect them to review, audit, rollback, and collaboration.
  • Define repository, working tree, commit, history, branch, remote, clone, and distributed ownership in beginner-friendly language.
  • Distinguish operations that use only local repository data from operations that communicate with another repository.
  • Compare centralized and distributed version-control architectures without turning either model into a caricature.
  • Read a small commit graph as connected snapshots and understand that a branch is a movable name for a commit, not a copied folder.
  • Use read-only Git inspection commands to verify repository location, current branch, status, and visible history.

1. The problem: files change, teams change, and memory is not a control system

Imagine a team maintaining a deployment runbook. On Monday the runbook says to deploy image api:2.7. On Tuesday an engineer changes it to api:2.8. On Wednesday an incident begins and someone asks four questions: what changed, who recorded the change, what did the file look like before it, and which other changes were made at the same time?

A folder named runbook-final, runbook-final-2, and runbook-really-final can preserve copies, but it does not provide a dependable change model. Version control records deliberate checkpoints and relationships between them. It gives a team a shared language for comparing states, reviewing changes, returning to known states, and exchanging work.

Mental model: version control is a history of intentional project states plus metadata and relationships. Git is not merely an “undo button,” and it is not a live folder-synchronization service.

2. Think in snapshots first

A snapshot is the project state Git records at a particular checkpoint. A commit is the Git object that identifies such a recorded state and connects it to its parent commit or commits. Later chapters will inspect the object database precisely. For now, the key idea is that each commit lets Git answer, “What project state did we record here, and which earlier commit led to it?”

This is different from imagining that Git stores a folder named “version 1,” another complete folder named “version 2,” and so on. Unchanged content can be reused internally, while the history still behaves conceptually like a sequence/graph of project snapshots.

A branch name points at the latest commit in one line of history
flowchart TD
  W["Working tree \nfiles you edit"] -->|record an intentional checkpoint| C1["Commit A \nsnapshot"]
  C1 --> C2["Commit B \nsnapshot"]
  C2 --> C3["Commit C \nsnapshot"]
  B["branch name: trunk"] -. points to .-> C3
  

The arrows between commits represent parent relationships. The dotted arrow is different: the branch name is a movable reference that currently names Commit C. When a new commit is created on that branch, the branch name normally moves to the new commit.

3. Vocabulary: the nouns must connect to one another

Repository. A Git repository is the version-controlled database and metadata for a project. In a normal non-bare repository, this data is stored under a .git directory beside a working tree. A bare repository stores repository data without a normal checked-out working tree and is useful as a collaboration endpoint.

Working tree. The ordinary files and directories you can open in an editor, run, build, or test. They are your current checked-out view plus any local edits.

Commit and history. A commit records a project snapshot plus metadata and parent relationship(s). History is the connected graph of commits reachable from names such as branches and tags.

Branch. A branch is a movable reference to a commit. Beginners often picture a branch as a copied directory; that picture breaks down quickly. A branch is better understood as a name that moves as new commits are made.

Remote. A remote is a configured name and URL/path for another repository. The conventional name origin is created by git clone for the source repository, but origin is not a Git keyword with magical network powers.

Clone. Cloning creates a new repository from another repository and normally checks out a working tree. Because the new clone has its own repository database, it can inspect history and create local commits without contacting the source repository.

4. Distributed ownership: every clone is a repository, not a thin client

In a distributed version-control system, a developer clone normally contains the project history needed for ordinary local work. That means git log, git diff, creating commits, and switching among already-known commits can happen without a network connection. Network communication is needed when you deliberately exchange objects and reference updates with another repository—for example through clone, fetch, and push.

Three repositories participating in one distributed workflow
flowchart LR
  O[("Bare repository \n\"origin\"")] <--> |fetch / push| A[("Alice clone \nrepo + working tree")]
  O <--> |fetch / push| B[("Bob clone \nrepo + working tree")]
  A -. local commits .-> A
  B -. local commits .-> B
  

Notice what the diagram does not show: Alice is not editing files “inside” the central repository. She edits her own working tree and records commits in her own clone. Exchange is explicit. Bob does the same. The bare repository is a convenient meeting point, not the only copy that can understand history.

5. Centralized versus distributed version control

Both centralized and distributed systems can support serious engineering. The architectural distinction is about where repository history and version-control operations live, not about one side being “modern” and the other “obsolete.”

Question Centralized model (conceptually) Distributed Git model
Where is the authoritative repository? Typically one server repository is central to most operations. Teams still choose authoritative remotes, but each clone is itself a repository.
Can I inspect known history without the server? Depends on the system and cached data. Normally yes; history is local in the clone.
Can I create a commit offline? Often server communication is part of committing. Yes; committing is a local repository operation.
How is collaboration coordinated? Through server-mediated version-control operations. By exchanging objects and ref updates among repositories, usually through shared remotes.
Does “distributed” mean there is no central server? Not applicable. No. Teams commonly designate GitHub, GitLab, an internal server, or a bare repository as the shared integration point.

6. Local operations versus repository-to-repository communication

One of the most useful beginner questions is: “Will this command need another repository?” The exact behavior of a command can be nuanced, but this first separation is powerful.

Command Primary role in this chapter Another repository required?
git status Inspect working tree/index state relative to the current commit. No.
git diff Compare local states. No.
git log Inspect commits already present locally. No.
git commit Create a new commit in the local repository. No.
git clone Create a repository from another repository. Yes—the source may be local or remote.
git fetch Obtain objects/refs from another repository without automatically integrating them into your current branch. Yes.
git push Transfer objects and request reference updates in another repository. Yes.

7. Inspect first: let Git tell you where you are

The course will repeatedly use read-only inspection before mutation. In an existing Git repository, these commands answer four different questions:

git --version
git rev-parse --show-toplevel
git branch --show-current
git status --short --branch
git log --oneline --decorate --graph --all -8

git rev-parse --show-toplevel identifies the root of the working tree when you are inside one. git branch --show-current prints the current branch name when HEAD is attached to a branch. git status --short --branch gives a compact state summary. git log shows commits already known locally; --all asks it to consider all refs available in this repository.

Do not copy commands blindly into a valuable repository. The commands above are inspection commands. Later state-changing commands will be introduced only inside disposable labs with preflight checks.

8. Mini lab: create a disposable graph you can see

Create a temporary directory, then initialize a repository with an explicit branch name so the lesson does not depend on your machine's default-branch configuration. The Git commands are the same across platforms; only the file-creation helper differs.

Git Bash, Bash, or zsh

mkdir git-foundations-mini
cd git-foundations-mini
git init --initial-branch=trunk
git config user.name "Learner Example"
git config user.email "learner@example.invalid"
printf "%s\n" "service: api" > service.txt
git status --short --branch
git add service.txt
git commit -m "docs: record service name"
printf "%s\n" "environment: staging" >> service.txt
git diff -- service.txt
git add service.txt
git commit -m "docs: add environment"
git log --oneline --decorate --graph --all

PowerShell: equivalent file creation

New-Item -ItemType Directory git-foundations-mini | Out-Null
Set-Location git-foundations-mini
git init --initial-branch=trunk
git config user.name "Learner Example"
git config user.email "learner@example.invalid"
"service: api" | Set-Content -Encoding utf8 service.txt
git status --short --branch
git add service.txt
git commit -m "docs: record service name"
"environment: staging" | Add-Content -Encoding utf8 service.txt
git diff -- service.txt
git add service.txt
git commit -m "docs: add environment"
git log --oneline --decorate --graph --all

Your object IDs will differ. A representative final graph looks like:

* <oid-B> (HEAD -> trunk) docs: add environment
* <oid-A> docs: record service name

The important observation is not the hexadecimal text. It is that trunk names the newest commit and that the newest commit has the earlier commit as its parent.

9. Six beginner misconceptions to remove now

  • “GitHub is Git.” Git is the version-control system. GitHub is one hosting/collaboration product built around Git.
  • “A commit uploads my work.” A commit records work in your local repository. Upload/exchange is a separate operation such as push.
  • “A branch is another folder.” A branch is a reference to a commit. Multiple branches can share most of the same commit graph.
  • “Clone means download the current files.” A normal clone creates another repository and obtains history/refs as well as a checked-out working tree.
  • “Git watches and synchronizes files live.” Git records/exchanges states when you run version-control operations; it is not Dropbox-style live synchronization.
  • “A commit hash proves who authored the change.” Object IDs support content addressing/integrity. Author metadata is metadata; cryptographic signing and trust are separate topics.

10. Why this mental model matters in DevOps

CI/CD systems build a specific commit. Infrastructure-as-code review compares changes between commits. GitOps controllers observe repository state and reconcile desired state. Release tooling places names such as tags on particular commits. Incident responders ask which commit introduced a behavior. These workflows are reliable only when the team can identify, exchange, and reason about immutable recorded states and the refs that name them.

A productive DevOps habit therefore begins before automation: make history reviewable, know which repository/ref you are operating on, and verify state before changing it.

11. Verification checklist

  • You can explain why a clone is a repository in its own right.
  • You can distinguish a commit from a branch name.
  • You can name at least three operations that use only local repository data.
  • You can explain why a local commit does not automatically appear in another clone.
  • You can run git rev-parse --show-toplevel, git status, and git log to establish context before modifying a repository.

12. Knowledge check

Question 1. Alice creates a commit while disconnected from the network. Is that compatible with Git’s distributed model?

Question 2. What does the name <code>trunk</code> represent in the mini lab?

Question 3. Bob runs <code>git log</code> and cannot see Alice’s new commit. Does that prove Alice never committed it?

Question 4. Why is “Git is a backup” an incomplete statement?

Question 5. Which inspection command is a good first check when you are unsure which repository your shell is inside?

13. Summary

Git becomes easier when you stop treating it as a collection of magic commands. A working tree is the editable view. A repository stores version-control data. Commits are connected recorded snapshots. Branches are movable names for commits. Clones are independent repositories. Remotes are configured paths/URLs to other repositories. Local history changes stay local until an explicit exchange operation occurs.

Next

Turn the mental model into an observable workflow

Lesson 2 builds a disposable repository from scratch, stages and commits changes, creates a bare collaboration repository, and watches two clones exchange history with fetch and push.

Authoritative references

 Git documentation
 Git tutorial
 Git glossary
 Pro Git — Getting Started

Keep the academy open

Support free, practical DevOps education.

Every lesson is designed to remain readable in a browser, downloadable from GitHub, and usable without a paid learning platform. Contributions help expand and maintain the curriculum.

Ethereum / ERC-20
0x716c4Ab160C4B66F31a28AE2448BfF68fc3a2ef0 Send only Ethereum/ERC-20 compatible assets to this address.