1.1 Repository and Snapshots
Git is a version control system. It helps you record project states over time, compare them, inspect them, undo them, and combine work from different people.
Why not copy folders manually?
Beginners often create folders like project-v1, project-final, and project-final-new. This quickly becomes messy: you cannot tell what changed, and combining two people's edits becomes painful.
Git uses a different model. It records a meaningful project state as a commit. Each commit has an identifier, a message, and a link to its parent commit.
What is a repository?
A repository is where Git stores project history. After Git is initialized in a project folder, a hidden .git directory appears. It stores commit objects, branches, configuration, the index, and other metadata.
.git directory. In normal learning and work, use commands such as git status, git add, and git commit.A snapshot is more than a text diff
For now, think of a commit as a snapshot: it represents the full project state at one moment. Git internally compresses and reuses data, but you do not need those storage details at the beginning.
Your first tiny repository
mkdir hello-git
cd hello-git
git initAfter git init, the folder becomes a Git repository. You do not have any commits yet; you have only told Git, "Start tracking this project here."
The core map for learning Git
You will repeatedly meet three areas:
- Working tree: the real files you are editing.
- Staging area / index: the candidate list for the next commit.
- Repository history: the saved chain of commits.
Understanding these areas matters more than memorizing commands.