2025-03-14 21:59:59 -06:00
|
|
|
# diff
|
|
|
|
|
|
|
|
|
|
> Compare files and directories.
|
2026-02-18 06:55:01 -07:00
|
|
|
> See also: `delta`, `difft`.
|
2025-03-14 21:59:59 -06:00
|
|
|
> More information: <https://manned.org/diff>.
|
|
|
|
|
|
|
|
|
|
- Compare files (lists changes to turn `old_file` into `new_file`):
|
|
|
|
|
|
2026-06-12 17:51:25 -06:00
|
|
|
`diff {{path/to/old_file}} {{path/to/new_file}}`
|
2025-03-14 21:59:59 -06:00
|
|
|
|
|
|
|
|
- Compare files, ignoring white spaces:
|
|
|
|
|
|
2026-06-12 17:51:25 -06:00
|
|
|
`diff {{[-w|--ignore-all-space]}} {{path/to/old_file}} {{path/to/new_file}}`
|
2025-03-14 21:59:59 -06:00
|
|
|
|
|
|
|
|
- Compare files, showing the differences side by side:
|
|
|
|
|
|
2026-06-12 17:51:25 -06:00
|
|
|
`diff {{[-y|--side-by-side]}} {{path/to/old_file}} {{path/to/new_file}}`
|
2025-03-14 21:59:59 -06:00
|
|
|
|
|
|
|
|
- Compare files, showing the differences in unified format (as used by `git diff`):
|
|
|
|
|
|
2026-06-12 17:51:25 -06:00
|
|
|
`diff {{[-u|--unified]}} {{path/to/old_file}} {{path/to/new_file}}`
|
2025-03-14 21:59:59 -06:00
|
|
|
|
|
|
|
|
- Compare directories recursively (shows names for differing files/directories as well as changes made to files):
|
|
|
|
|
|
2026-06-12 17:51:25 -06:00
|
|
|
`diff {{[-r|--recursive]}} {{path/to/old_directory}} {{path/to/new_directory}}`
|
2025-03-14 21:59:59 -06:00
|
|
|
|
|
|
|
|
- Compare directories, only showing the names of files that differ:
|
|
|
|
|
|
2026-06-12 17:51:25 -06:00
|
|
|
`diff {{[-r|--recursive]}} {{[-q|--brief]}} {{path/to/old_directory}} {{path/to/new_directory}}`
|
2025-03-14 21:59:59 -06:00
|
|
|
|
|
|
|
|
- Create a patch file for Git from the differences of two text files, treating nonexistent files as empty:
|
|
|
|
|
|
2026-06-12 17:51:25 -06:00
|
|
|
`diff {{[-a|--text]}} {{[-u|--unified]}} {{[-N|--new-file]}} {{path/to/old_file}} {{path/to/new_file}} > {{path/to/diff.patch}}`
|
2025-03-14 21:59:59 -06:00
|
|
|
|
2026-06-12 17:51:25 -06:00
|
|
|
- Compare files, showing output in color, trying hard to find the smallest set of changes:
|
2025-03-14 21:59:59 -06:00
|
|
|
|
2026-06-12 17:51:25 -06:00
|
|
|
`diff {{[-d|--minimal]}} --color=always {{path/to/old_file}} {{path/to/new_file}}`
|