[Git] Check a diff for whitespace errors

Created on November 30, 2026

git diff --check reports problems such as trailing whitespace. In this example, adding a line to the tracked sample.txt leaves a trailing space after beta.

git diff --check
sample.txt:2: trailing whitespace.
+beta

A clean checked diff typically produces no output and exits with status 0. Use git diff --cached --check for staged changes. The check reports issues for you to fix separately.

Reference

Git