Tracking Changes

How to use `git status` to see what's changed and `git add` to prepare files for your next commit.

Version Control4 min readConcept 4 of 29

Status and Add

git status is your radar. It tells you exactly what Git sees in your Working Directory and Staging Area at any given moment.

git add is your staging tool. It takes modified or new files from your Working Directory and places them onto the Staging Area, ready to be committed.

Why it matters

Without git status, you are flying blind. You might accidentally commit a secret password file, or forget to include a crucial CSS file in your snapshot.

By constantly checking git status before you run git add, you maintain total control over your project history.

File states in Git

Files in Git can be in one of four states:

1. **Untracked**: New files Git has never seen before.

2. **Unmodified**: Files Git knows about, but haven't changed since the last commit.

3. **Modified**: Files Git knows about that you've changed, but haven't staged yet.

4. **Staged**: Files you have marked with git add to go into the next commit.

Check yourself

Pick an answer to lock it in, then read why. Getting one wrong is part of how it sticks.

  1. 1What does the `git status` command do?
  2. 2If you create a brand new file `index.html` in your repository, what state is it in initially?
  3. 3Why might a senior developer avoid using `git add .`?

Remember this

  • git status shows the state of your files.
  • git add <file> moves a file to the Staging Area.
  • Always run git status before git add.

Done with this concept?

Mark it complete to track your progress. No login needed.