# Tracking Changes

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

Subject: Version Control | Lesson 4 of 29 | 4 min read
Interactive lesson: https://codewithanimation.in/git/git-add-and-status
Previous: [Initializing a Repository](https://codewithanimation.in/git/git-init.md) | Next: [Committing Changes](https://codewithanimation.in/git/git-commit.md)

## 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.

## Common mistake: Blindly adding everything

The #1 mistake beginners make is reflexively typing `git add .` (which adds every changed file in the directory) without running `git status` first. This leads to accidentally committing `console.log` statements, broken experimental code, or huge `node_modules` folders.

## Tip: The 'Look Before You Leap' rule

Always type `git status` immediately before AND immediately after you type `git add`. This confirms exactly what you are about to stage, and then verifies that you staged it correctly.

## Try it: Inspect and stage file changes

Run `git status`, then stage individual changes and compare the working tree with the index.

The animation is on the lesson page and is not part of this text version: https://codewithanimation.in/git/git-add-and-status

## Check yourself

### Question 1

What does the `git status` command do?

- A. It saves your current progress to the repository.
- B. It displays the state of the Working Directory and the Staging Area.
- C. It shows a list of all your previous commits.
- D. It checks the server to see if anyone else has made changes.

Correct answer: B

`git status` is your primary diagnostic tool. It lists which files are untracked, which are modified, and which are staged for the next commit.

- Why not A: That is `git commit`.
- Why not C: That is `git log`.
- Why not D: Git is local. To check the remote server, you'd use `git fetch`.

### Question 2

If you create a brand new file `index.html` in your repository, what state is it in initially?

- A. Staged
- B. Modified
- C. Untracked
- D. Committed

Correct answer: C

Any completely new file created in a Git repository starts as 'Untracked'. Git sees it, but will ignore it until you explicitly tell Git to track it using `git add`.

- Why not A: You have to run `git add index.html` to stage it.
- Why not B: Git doesn't consider a file 'modified' until it is already tracking it.
- Why not D: You haven't added or committed it yet.

### Question 3

Why might a senior developer avoid using `git add .`?

- A. Because it deletes all your untracked files.
- B. Because it takes too long to execute on large projects.
- C. Because it blindly stages everything, which risks committing unfinished code or sensitive files.
- D. Because it only adds text files and ignores images.

Correct answer: C

While `git add .` is convenient, it's dangerous if you haven't reviewed your changes. It's safer to add specific files (`git add index.html`) or review `git status` carefully before using the catch-all dot.

- Why not A: `git add .` does not delete anything.
- Why not B: Git is incredibly fast. Speed isn't the issue.
- Why not D: `git add .` adds everything, including images.

## 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`.
