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:

git status -s

Display a short summary of the working directory's status
  1. Mark the file as intent-to-add:
  1. Review it as an unstaged diff:
  1. If you want to undo the intent-to-add entry:

git reset -- <path>

Unstage changes for the specified `path` while keeping the working-directory edits intact.

Variations

  • If you actually want to stage the full content of the new file, use git add <path>.

git add <path>

Stages changes in the specified <path> so they are included in the next commit.
  • If you want to review what you already staged, use git diff --staged.

git diff --staged

Displays changes between the index and the last commit.

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

  • git status for spotting untracked files.

git status

Show the status of the current repository

Sign in to Git Examples