What you will learn
- A repository is a project folder whose changes Git tracks.
- The working tree contains the actual files you edit.
- Staging chooses what enters the next saved snapshot.
What version control solves
When you edit the same project over several days, it becomes surprisingly easy to lose a working version. Sending files named final, final-new, and final-really-final does not solve that problem. Git stores checkpoints called commits so you can inspect what changed and return to a known state. You begin with a folder on your own computer; no GitHub account is needed for the first exercises. We will create a small learning journal, save its first version, and inspect the history. By the end, you will know exactly what Git has recorded and what remains unsaved.
- A repository is a project folder whose changes Git tracks.
- The working tree contains the actual files you edit.
- Staging chooses what enters the next saved snapshot.
- A commit records that staged snapshot with a useful message.
- GitHub is a remote hosting service; Git itself works locally without GitHub.
Words you need
A
A repository is a project folder whose changes Git tracks.
The
The working tree contains the actual files you edit.
Staging
Staging chooses what enters the next saved snapshot.
A
A commit records that staged snapshot with a useful message.
Examples
Create an empty learning repository
mkdir etg-journal && cd etg-journal
git initOutputInitialized empty Git repository in .../etg-journal/.git/
Explanation: Git creates hidden repository metadata. It does not automatically add or save files.
Write a note and stage it
printf "Today I learned how commits work.\n" > notes.txt
git add notes.txt
git status --shortOutputA notes.txt
Explanation: The A in the first column tells you notes.txt is staged. The file is ready for a commit but is not saved in history yet.
Save and inspect your first checkpoint
git -c user.name="Demo Learner" -c user.email="learner@example.invalid" commit -m "Add first learning note"
git log -1 --onelineOutputabc1234 Add first learning note
Explanation: The exact commit ID will be different. The log proves that the snapshot is recorded in the repository history.
Practical chapter project
Build and verify
Create a three-entry learning journal, commit each entry separately, and show the final three entries with git log --oneline.
How to check the result
Record your actual starting state and the visible final result. If a service account is needed, confirm permission and cost protection first. Your project meets the target when someone else can repeat it safely and see the intended outcome.
Check your understanding
01 Does Git require a GitHub account?
No. Local repositories, commits and history work without a remote hosting account.
02 What is the difference between staging and committing?
Staging selects changes; committing records the staged snapshot in history.
03 Why use a clear commit message?
It explains the purpose of a saved change to your future self and collaborators.
04 Where does Git store repository history?
Inside the hidden .git directory of the local repository.
Summary
A repository is a project folder whose changes Git tracks. The working tree contains the actual files you edit. Complete the chapter project before opening Chapter 2.