AI Hints
Home›Git & GitHub Tutorial›Your First Commit
Git & GitHub · Lesson 8 of 144

Staging with git add

Choosing what to save.

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

Saving in Git takes two steps. First, you choose which changes go into the next snapshot. That's called staging. Then you take the snapshot. Git add is the first step.

Staging with git add
From the video: Staging with git add
  • Saving takes two steps
  • Step one: choose, with git add
  • Step two: take the snapshot

git add

We type git add, and the file name. Again, silence means success. Now status. The file has moved, to changes to be committed, and it's shown in green. It's staged. It will go into the next snapshot.

git
git add index.html
git status
On branch main

No commits yet

Changes to be committed:
  (use "git rm --cached <file>..." to unstage)
        new file:   index.html

The staging area

Think of the staging area like a box you're packing, before you post it. Git add puts a change into the box. You can add one file, or many. When the box looks right, you seal it, and that's the commit.

Summary

git add stages a change, which means it's chosen for the next snapshot. Next, we take the snapshot itself.

Key takeaways
  • git add <file>
  • Staged files show in green
  • Staging = choosing
Next up: Your First Commit — git commit -m