Cheatsheet: Why git exists
Voice anchor
Section titled “Voice anchor”Git stores snapshots. Every other command is just navigating those snapshots.
This is the single sentence that makes every later git lesson coherent. Hold it.
Definitions
Section titled “Definitions”| Term | Definition |
|---|---|
| Version control | A system that records changes to a file or set of files over time so that any specific version can be recalled later. |
| Commit | A saved snapshot of the entire project state at a specific moment, with a label and a timestamp. |
| Snapshot | A complete picture of every file in the project at the moment a commit is made. |
| Centralized version control | An architecture where one server holds the canonical project history; clients connect to it for history operations. Example: Subversion, CVS. |
| Distributed version control | An architecture where every clone holds the full project history; operations are local; sharing happens by pushing between clones. Example: git, Mercurial. |
| Clone | A complete copy of a project’s full history, made by a developer to a local machine. |
| Repository | The directory tree plus the git history that describes how the directory tree evolved. |
Three signs a project needs version control
Section titled “Three signs a project needs version control”- More than one person edits the project. Overwrites are inevitable without version control.
- The project evolves over time and earlier versions might matter. If you might want to recover an earlier state, version control is the system that lets you.
- The consequences of a mistake are non-trivial. When rollback matters, the cost of not having version control becomes asymmetric: small effort to set up, large pain to do without when needed.
Three reasons distributed beats centralized in practice
Section titled “Three reasons distributed beats centralized in practice”- Offline work is possible because the full history is local
- Resilience against central-server data loss because every clone is a backup
- Cheap branching because branches are local and lightweight, not server-roundtripped
The mental-model trap to avoid
Section titled “The mental-model trap to avoid”Treating git as a diff-tracking system rather than a snapshot system. Git does store diffs efficiently under the hood, but the conceptual model is snapshots. The snapshot model makes every later command coherent. The diff model leads to confusion when branching, merging, and rebasing show up later.
What is in L2
Section titled “What is in L2”L2 makes the snapshot model real. It introduces:
git initto start tracking a projectgit statusto see what has changedgit addto stage changes for the next snapshotgit committo take the snapshot- A
.gitignorefile to tell git what to ignore
L2 starts where L1 ends.