Black Friday sale: 30% off Flywrite

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

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. Checked .
  2. GitHub Docs: Commits. Checked .
  3. OpenAI Codex docs: Developer commands (CLI). Checked .
  4. Flywrite docs: Checkpoints & versions. Checked .

Write with your agent in a writing app.

Buy now