Your daily Git workflow

Stage changes

Select the files and changes that should be part of the next commit.

8 minute lesson

~~~

The staging area lets you decide exactly what the next commit will contain.

Stage one file with:

git add README.md

Staging is not saving the file. Your editor already did that. git add copies the file’s current content into the index.

Verify the staged change:

git status
git diff --staged

If you edit README.md again, the new edit remains in the working tree. The index still contains the version you staged earlier. Run both commands:

git diff
git diff --staged

This is useful when one file contains two unrelated changes. You can stage only selected parts with git add -p, review each hunk, and leave the rest for another commit.

Avoid git add . until you have checked git status. It is easy to include generated files or unrelated edits.

Exercise: make two edits to one file. Stage it after the first edit, make the second edit, then predict which content the next commit would record.

Lesson completed

Take this course offline

Get every free book, course edition, and software download.

Get the download library →