# git diff

git diff shows what changed in your files, line by line, against the last commit or the staging area. The forms you'll use and how to read the output.

**Definition:** git diff is the Git command that shows what changed between two versions of your files, line by line, with removed lines marked - and added lines marked +.

## The forms you'll use

| Command | Shows |
| --- | --- |
| `git diff` | Changes not yet staged for the next commit |
| `git diff --staged` | Changes staged for the next commit |
| `git diff HEAD` | Every change since the last commit |
| `git diff <commit>` | Every change since that commit |
| `git diff -- issue-42.md` | Any of the above, for one file |

## How to read it

```diff
diff --git a/issue-42.md b/issue-42.md
--- a/issue-42.md
+++ b/issue-42.md
@@ -3 +3 @@
-This week we shipped three small updates.
+This week brought three small updates.
```

The `---` and `+++` lines name the old and new file. Each `@@` line gives the line numbers of a change. A line starting with `-` was removed and a line starting with `+` was added; lines with neither are context.

## For prose, compare words

Git compares lines. In a Markdown draft a paragraph is often one long line, so a one-word edit shows the whole paragraph twice. A [word diff](/glossary/word-diff) marks just the words that changed.

## In Flywrite

Flywrite has no diff view: it saves checkpoints and restores from them. Each checkpoint is a Git commit, so in the project's terminal, `git diff HEAD` shows what changed since the latest checkpoint, in files that checkpoint already tracked. It needs Git on the command line. Codex's `/diff` command shows the Git diff from inside Codex, new files included, and in a project connected to GitHub, each checkpoint links to its commit page on github.com, where you can select a file to view its diff. More in the guide to [rolling back an agent's edits](/guides/review-and-undo-agent-edits).

## Questions

### Why doesn't git diff show my new file?

git diff leaves out files Git doesn't track yet. A new file shows up once it's added to Git; in a Flywrite project, the next checkpoint adds it.

### What's the difference between git diff and git diff HEAD?

Plain git diff compares your files with the staging area, so it shows only changes you haven't staged. git diff HEAD compares them with the last commit, staged or not.

## Sources

1. [Git documentation: git-diff](https://git-scm.com/docs/git-diff), checked 2026-11-10
2. [GitHub Docs: Commits](https://docs.github.com/en/pull-requests/reference/commits), checked 2026-11-04
3. [OpenAI Codex docs: Developer commands (CLI)](https://learn.chatgpt.com/docs/developer-commands?surface=cli), checked 2026-11-17
4. [Flywrite docs: Checkpoints & versions](/docs/checkpoints-and-versions), checked 2026-11-17

---

This is the Markdown copy of https://flywrite.app/glossary/git-diff.
