git diff --no-index a.txt b.txt

Category: Git - Core

git diff --no-index a.txt b.txt

Diff two files outside a repository

The --no-index mode compares two arbitrary files or directories with the normal diff engine, even outside any Git repository. It reports differences with the same patch formatting Git always uses. Useful for spotting drift between two config files or generated outputs.
Looking for more? Search all 7,657 commands — works offline, in English or Spanish, and fixes typos.