Sign In

Review new files in diffs with git add -N

When you create a new file, it can be awkward to review it in a diff-first workflow:

  • git status clearly shows the untracked file.
  • git diff often shows nothing, because Git can only diff between two known states.

git add -N <path> fixes that by creating an empty index entry for the new file ("intent to add"). From then on, git diff can show the file as a normal patch without actually staging the contents.

Step by step

  1. Confirm the file is untracked:

  2. Mark the file as intent-to-add:

  3. Review it as an unstaged diff:

  4. If you want to undo the intent-to-add entry:

Variations

Note: for intent-to-add paths, git diff --staged output can look surprising. That’s normal: the index entry is intentionally empty.

Common mistakes

  • Mixing up git diff (working tree vs index) with git diff --staged (index vs HEAD).
  • Assuming git add -N stages file contents. It doesn’t.

See also

Sign in to Git Examples