2014-02-02 13:26:10 +01:00
|
|
|
# diff
|
|
|
|
|
2016-01-07 18:31:27 +01:00
|
|
|
> Compare files and directories.
|
2024-06-17 18:21:33 +02:00
|
|
|
> More information: <https://manned.org/diff>.
|
2014-02-02 13:26:10 +01:00
|
|
|
|
2019-05-09 18:16:35 +02:00
|
|
|
- Compare files (lists changes to turn `old_file` into `new_file`):
|
2014-02-02 13:26:10 +01:00
|
|
|
|
2019-05-09 18:16:35 +02:00
|
|
|
`diff {{old_file}} {{new_file}}`
|
2014-02-02 13:26:10 +01:00
|
|
|
|
2024-06-12 07:43:11 +02:00
|
|
|
- Compare files, ignoring white spaces:
|
2014-02-02 13:26:10 +01:00
|
|
|
|
2025-03-08 16:43:04 +02:00
|
|
|
`diff {{[-w|--ignore-all-space]}} {{old_file}} {{new_file}}`
|
2014-02-02 13:26:10 +01:00
|
|
|
|
2018-10-19 10:42:28 +01:00
|
|
|
- Compare files, showing the differences side by side:
|
2014-02-02 13:26:10 +01:00
|
|
|
|
2025-03-08 16:43:04 +02:00
|
|
|
`diff {{[-y|--side-by-side]}} {{old_file}} {{new_file}}`
|
2014-02-02 13:26:10 +01:00
|
|
|
|
2024-06-12 07:43:11 +02:00
|
|
|
- Compare files, showing the differences in unified format (as used by `git diff`):
|
2018-10-19 10:42:28 +01:00
|
|
|
|
2025-03-08 16:43:04 +02:00
|
|
|
`diff {{[-u|--unified]}} {{old_file}} {{new_file}}`
|
2018-10-19 10:42:28 +01:00
|
|
|
|
2024-06-12 07:43:11 +02:00
|
|
|
- Compare directories recursively (shows names for differing files/directories as well as changes made to files):
|
2014-02-02 13:26:10 +01:00
|
|
|
|
2025-03-08 16:43:04 +02:00
|
|
|
`diff {{[-r|--recursive]}} {{old_directory}} {{new_directory}}`
|
2014-02-02 13:26:10 +01:00
|
|
|
|
2016-01-07 18:31:27 +01:00
|
|
|
- Compare directories, only showing the names of files that differ:
|
2014-02-02 13:26:10 +01:00
|
|
|
|
2025-03-08 16:43:04 +02:00
|
|
|
`diff {{[-r|--recursive]}} {{[-q|--brief]}} {{old_directory}} {{new_directory}}`
|
2021-09-20 13:09:41 +03:00
|
|
|
|
|
|
|
- Create a patch file for Git from the differences of two text files, treating nonexistent files as empty:
|
|
|
|
|
2025-03-08 16:43:04 +02:00
|
|
|
`diff {{[-a|--text]}} {{[-u|--unified]}} {{[-N|--new-file]}} {{old_file}} {{new_file}} > {{diff.patch}}`
|
2024-03-17 01:12:22 +11:00
|
|
|
|
|
|
|
- Compare files, showing output in color and try hard to find smaller set of changes:
|
|
|
|
|
2025-03-08 16:43:04 +02:00
|
|
|
`diff {{[-d|--minimal]}} --color=always {{old_file}} {{new_file}}`
|