AI Hints
Home›Git & GitHub Tutorial›The Three Areas
Git & GitHub · Lesson 11 of 144

Why Staging Helps

One change, one commit.

⏱ 2 min read▶ Video at 11:07🎓 Free
Watch this lesson in the Git & GitHub courseWatch on YouTube ↗Full Git & GitHub course

Why not just save everything at once? Because staging lets you split your work into clean, separate commits. Each commit does one thing, and has a clear message.

Why Staging Helps
From the video: Why Staging Helps
  • Why not save everything at once?
  • Staging lets you choose
  • One commit, one idea

Two changes, two commits

Say we changed two files. We fixed the home page, and we started a style file. Status shows both. But they're different ideas, so we'll commit them separately. Add only the home page, and commit it. Then add the style file, and commit that. Our history now tells two clear little stories, instead of one messy one.

git
git status --short
 M index.html
?? style.css
git add index.html
git commit -m "Fix home page title"
[main f11fd1d] Fix home page title
 1 file changed, 1 insertion(+), 1 deletion(-)
git add style.css
git commit -m "Add basic styles"
[main 1f47692] Add basic styles
 1 file changed, 1 insertion(+)
 create mode 100644 style.css

Adding everything

Sometimes you really do want to stage everything. Git add, then a dot, adds every change in the current folder. Status shows both files are now staged. Use it when all your changes belong together.

git
git add .
git status --short
A  blog.html
M  index.html

Summary

Staging lets you choose what goes into each commit. Git add dot stages everything. Next, how to write commit messages people can actually use.

Key takeaways
  • Stage only what belongs together
  • One idea per commit
  • git add . stages everything
Next up: Good Commit Messages — short, clear, and useful