git add: choose what goes in the picture
Staging files — the checklist for the next save.
git add never saves anything — it only marks files for the next photograph.
01Putting a file on the checklist
You created or changed a file, and git status lists it as untracked or modified. Nothing about it is saved yet. To put it on the checklist for the next commit, you stage it: git add followed by the file's name. The file's current content — exactly as it is at this second — is what goes on the checklist.
Staging is a promise, not a delivery. If you edit the file again after staging, the checklist still holds the version you staged, not the newer one on disk — and status will show the file in both groups at once, which is git telling you the two have drifted apart. This surprises everyone exactly once.
git add notes.txt
git statusgit add snapshots the file as it is at that moment. Edit again afterwards and the new edit is unstaged until you add again. If status shows a file under both groups, that is what happened.
02Everything at once
Most of the time you want everything in the folder staged, and typing every filename gets old fast. A dot means this folder and everything inside it: git add .. It is the everyday form, and it is what most developers type most of the time.
The trade-off: the dot stages everything, including the file you forgot was a mess. In real projects you will sometimes go back to staging files by name, precisely to keep messy work out of a photograph that is supposed to be clean. Both forms are correct — they differ only in how much control you keep.
git add .03What status looks like after adding
After git add, status moves the file into a new group — Changes to be committed — with new file: in front of it. That is the checklist, loaded and ready. The summary line at the bottom changes too: git no longer says nothing added to commit, because now there is.
From here there is exactly one move left in the pipeline: the photograph itself. That is the next course.
Tools that auto-save every change produce history where every typo is a permanent entry. Git's staging step exists so humans decide what a save point means. The checklist is where you compose the story you will read later.
Practice
Stage your first file.
01.Create notes.txt with any text inside.
hint: Try: echo "shopping list" > notes.txt
02.Stage it with git add.
hint: Try: git add notes.txt (or git add .)