LinuxCommandLibrary
GitHubF-DroidGoogle Play Store

diff3

three-way file comparison and merge

TLDR

Compare three files
$ diff3 [path/to/file1] [path/to/file2] [path/to/file3]
copy
Show all changes outlining conflicts
$ diff3 -A [path/to/file1] [path/to/file2] [path/to/file3]
copy

SYNOPSIS

diff3 [options] myfile oldfile yourfile

DESCRIPTION

diff3 compares three files line by line, showing differences and conflicts. It's typically used for three-way merges where one file is the common ancestor and two files are modified versions.The output format is suitable for merge conflict resolution.

PARAMETERS

-A, --show-all

Show all changes, bracketing conflicts
-e, --ed
Output ed script
-E, --show-overlap
Like -e but bracket conflicts
-m, --merge
Output the merged file directly (implies -A unless -e, -E, or -x is given)
-x, --overlap-only
Output overlapping (conflicting) changes only
-3, --easy-only
Output non-overlapping changes from the third file only
-T, --initial-tab
Make tabs line up by prefixing a tab

INSTALL

sudo apt install diffutils
copy
sudo dnf install diffutils
copy
sudo pacman -S diffutils
copy
sudo apk add diffutils
copy
sudo zypper install diffutils
copy
brew install diffutils
copy
nix profile install nixpkgs#diffutils
copy

CAVEATS

File order matters: mine, older, yours. Commonly used internally by version control systems. Part of GNU diffutils.

SEE ALSO

diff(1), merge(1), patch(1)

RESOURCES

Copied to clipboard
Kai