# diff & log — Git

Source: https://www.geekswithgeeks.com/en/git/git-diff-log

> See exactly what changed, and browse the project's history.

## git diff

Shows line-by-line changes not yet staged. Add `--staged` to see what's already in the staging area.

```bash
git diff
git diff --staged
```

Output:

```
-const port = 3000;
+const port = 8080;
```

## git log

Browse commit history — author, date, message, and a unique hash for each commit.

```bash
git log --oneline -5
```

Output:

```
a1b2c3d Add landing page markup
9f8e7d6 Initial commit
```

**Quiz:** Which command shows staged changes not yet committed?

- [ ] git diff
- [x] git diff --staged
- [ ] git log

*Answer:* git diff --staged. Plain `git diff` compares working directory to the staging area; `--staged` compares staging area to the last commit.
