Warm-up
Think of a file you have edited more than once. How did you distinguish its versions?
Think of a file you have edited more than once. How did you distinguish its versions?
There is no wrong answer: this primes what you already know.
The problem
Why keep five copies of a file called final, final2 and final-final? A version control system gives each meaningful state an identity and a history.
After this lesson you can
Explain snapshots and history.
Distinguish Git from a hosting service.
Inspect two versions of a file.
Key terms
Full glossarySay what each term means, then open it to check.
Commit · preview, covered in lesson 7
Object identifying a root tree, parent(s), metadata and message.
Visual mental model
- Edit file
- Save snapshot
- Edit again
- Save next snapshot
Build the mental model
Git records selected project states over time. A commit is a named-by-hash record of a snapshot, with metadata and links to earlier commits. You choose when to save a meaningful state; editing a file alone does not create a commit. This makes it possible to inspect old work, compare versions and collaborate without exchanging entire project folders.
Simulation: commits are named by hash and link to their parent. Editing alone never adds a node.
Under the hood
Git is the local version control system. GitHub, GitLab and similar services host repositories and add collaboration features. You can learn nearly everything in this book without internet access. A local commit is not automatically a backup: a disk failure can destroy both your working files and the local repository.
Common mistake · important nuance
One snapshot can include many files. Git is not a replacement for automated backups, nor does it automatically save every keystroke.