diff--Show differences between revisions

The diff command is used to compare different revisions of files. The default action is to compare your working files with the revisions they were based on, and report any differences that are found.

If any file names are given, only those files are compared. If any directories are given, all files under them will be compared.

The exit status for diff is different than for other cvsnt commands; for details the section called “CVS's exit status”.

diff options

These standard options are supported by diff (the section called “Common command options”, for a complete description of them):

-D date

Use the most recent revision no later than date. See -r for how this affects the comparison.

-k kflag

Process keywords according to kflag. See Chapter 13, Keyword substitution.

This option is for use when diffing two repository revisions - it will probably not do what you expect when diffing against a sandbox file.


Local; run only in current working directory.


Examine directories recursively. This option is on by default.

-r tag

Compare with revision tag. Zero, one or two -r options can be present. With no -r option, the working file will be compared with the revision it was based on. With one -r, that revision will be compared to your current working file. With two -r options those two revisions will be compared (and your working file will not affect the outcome in any way).

One or both -r options can be replaced by a -D date option, described above.

The following options specify the format of the output. They have the same meaning as in GNU diff.

-0 -1 -2 -3 -4 -5 -6 -7 -8 -9
  -C nlines
-e --ed
-t --expand-tabs
-f --forward-ed
-w --ignore-all-space
-B --ignore-blank-lines
-i --ignore-case
-I regexp
-b --ignore-space-change
-T --initial-tab
-L label
-d --minimal
-N --new-file
-n --rcs
-s --report-identical-files
-y --side-by-side
-F regexp
-H --speed-large-files
-a --text
  -U nlines
-V arg
-W columns

diff examples

The following line produces a Unidiff (-u flag) between revision 1.14 and 1.19 of backend.c. Due to the -kk flag no keywords are substituted, so differences that only depend on keyword substitution are ignored.

$ cvs diff -kk -u -r 1.14 -r 1.19 backend.c

Suppose the experimental branch EXPR1 was based on a set of files tagged RELEASE_1_0. To see what has happened on that branch, the following can be used:

$ cvs diff -r RELEASE_1_0 -r EXPR1

A command like this can be used to produce a context diff between two releases:

$ cvs diff -c -r RELEASE_1_0 -r RELEASE_1_1 > diffs

If you are maintaining ChangeLogs, a command like the following just before you commit your changes may help you write the ChangeLog entry. All local modifications that have not yet been committed will be printed.

$ cvs diff -u | less