Saltar al contenido principal

Git History & Key Concepts

Module 00 45 min

Section Objectives

  • Understand Git's origin and why it was created
  • Master the fundamental concepts: repository, commit, snapshot
  • Understand the Git object model
  • Distinguish the 3 areas of Git (working tree, staging, repository)

The Origin of Git

Linus Torvalds and the Linux Kernel

In 2005, Linus Torvalds (creator of Linux) found himself in a crisis:

  • The Linux kernel had thousands of contributors worldwide
  • The tool they used (BitKeeper) revoked its free license
  • They needed a new tool immediately — and it had to be better

Torvalds spent 10 days writing Git. His requirements:

RequirementExplanation
SpeedMust be fast even on large projects
DistributedNo central server needed
Non-linearStrong support for branching/merging
IntegrityData corruption must be detectable
Free and openNever depend on proprietary tools
Git's name

Torvalds chose the name "git" — British slang for "stupid person." He said: "I name all my projects after myself. First Linux, then git."

Git's Timeline


The 3 Areas of Git

This is the most important concept to understand in Git. Every file lives in one of these 3 areas:

AreaAlso CalledDescription
Working TreeWorking DirectoryYour files on disk as you edit them
Staging AreaIndex, CacheFiles marked "ready to commit"
Repository.git directoryPermanent history of all commits

Practical Analogy

Think of it like preparing a package to ship:

  • Working Tree = Your desk where you're working on items
  • Staging Area = The box where you're organizing what to ship
  • Repository = The warehouse where all shipped packages are stored

Key Concepts

What is a Repository?

A repository (or "repo") is a folder that Git tracks. It contains:

  • All your project files
  • A hidden .git folder with all version history
  • Configuration, branches, tags, etc.
my-project/
├── .git/ ← Git's "brain" (never touch manually!)
│ ├── HEAD ← Points to current branch
│ ├── config ← Repository configuration
│ ├── objects/ ← All Git objects (blobs, trees, commits)
│ └── refs/ ← Branch and tag references
├── src/
│ └── main.py
├── README.md
└── .gitignore

What is a Commit?

A commit is a snapshot of your project at a specific moment. Each commit contains:

FieldDescriptionExample
Hash (SHA-1)Unique identifiera3f4b2c
AuthorWho made the commitAlice <alice@example.com>
DateWhen it was committed2026-03-18 14:30
MessageDescription of changesAdd user login feature
ParentReference to previous commitf1d3e8a
TreeSnapshot of files(all files at that moment)

Git's Snapshot Model

Unlike older VCS (like SVN) that store differences (deltas), Git stores complete snapshots:

Efficient storage

Git doesn't store the full content of every file every time. If a file hasn't changed, Git just stores a reference to the identical file from the previous commit. This makes Git both accurate and storage-efficient.


Git's Object Types

Git stores everything as 4 types of objects (all identified by SHA-1 hash):

ObjectDescriptionExample
BlobContent of a fileThe bytes of main.py
TreeA directory listingLinks to blobs and sub-trees
CommitA snapshot with metadataHash, author, message, parent
TagA named reference to a commitv1.0.0 → commit a3f4b2c

The HEAD Pointer

HEAD is a special pointer that always indicates where you are in the repository:

  • In normal state: HEAD points to the current branch
  • In "detached HEAD" state: HEAD points directly to a commit

Summary

ConceptDefinitionAnalogy
RepositoryGit-tracked folderPhoto album
CommitSnapshot + metadataOne photo in the album
Working TreeYour files as they are nowPaper on your desk
Staging AreaFiles ready to commitBox ready to ship
HEADWhere you currently areBookmark in the album
Hash (SHA-1)Unique commit identifierPhoto serial number

Next Steps