Stage Changes
Staging picks the changes for the next snapshot. Nothing is saved until you stage it and commit it.
Stage one file
The command prints nothing. Silence means it worked.
$ git add notes.txtCheck the staging list
Status now lists the file under Changes to be committed.
$ git statusExample
$ git add notes.txt
$ git statusKey points
- The staging area is the list of changes for the next snapshot.
- Add moves a file’s changes onto that list.
- A file can be half staged: new changes wait until you add again.
- Add with a file name stages one file.
- Add with a dot stages every changed file in the folder.
- Staging never saves anything. It only prepares the save.
- Status shows staged changes under “Changes to be committed”.
Here, add stages the file and status shows the result. The words “new file” mean this snapshot will add notes.txt to the history for the first time.
Note
Stage small, related changes together. One idea per snapshot.
Try it Yourself
Edit the code, then press Run.
Running is simulated
Exercise
What does git add do?