As we mentioned earlier, the repository is like a time
machine. It keeps a record of every change ever committed,
and allows you to explore this history by examining previous
versions of files and directories as well as the metadata that
accompanies them. With a single Subversion command, you can
check out the repository (or restore an existing working copy)
exactly as it was at any date or revision number in the past.
However, sometimes you just want to
peer
into
the past instead of
going
into
the past.
There are several commands that can provide you with
historical data from the repository:
To find information about the history of a file or
directory, use the
svn log
command.
svn log
will provide you with a
record of who made changes to a file or directory, at what
revision it changed, the time and date of that revision, and,
if it was provided, the log message that accompanied the
commit.
$ svn log
------------------------------------------------------------------------
r3 | sally | Mon, 15 Jul 2002 18:03:46 -0500 | 1 line
Added include lines and corrected # of cheese slices.
------------------------------------------------------------------------
r2 | harry | Mon, 15 Jul 2002 17:47:57 -0500 | 1 line
Added main() methods.
------------------------------------------------------------------------
r1 | sally | Mon, 15 Jul 2002 17:40:08 -0500 | 1 line
Initial import
------------------------------------------------------------------------
Note that the log messages are printed in
reverse chronological order
by default.
If you wish to see a different range of revisions in a
particular order, or just a single revision, pass the
--revision
(-r
)
switch:
$ svn log --revision 5:19 # shows logs 5 through 19 in chronological order
$ svn log -r 19:5 # shows logs 5 through 19 in reverse order
$ svn log -r 8 # shows log for revision 8
You can also examine the log history of a single file or
directory. For example:
$ svn log foo.c
…
$ svn log https://foo.com/svn/trunk/code/foo.c
…
These will display log messages
only
for those revisions in which the working file (or URL)
changed.
If you want even more information about a file or
directory,
svn log
also takes a
--verbose
(-v
) switch.
Because Subversion allows you to move and copy files and
directories, it is important to be able to track path changes
in the filesystem, so in verbose mode,
svn
log
will include a list of changed paths in a
revision in its output:
$ svn log -r 8 -v
------------------------------------------------------------------------
r8 | sally | 2002-07-14 08:15:29 -0500 | 1 line
Changed paths:
M /trunk/code/foo.c
M /trunk/code/bar.h
A /trunk/code/doc/README
Frozzled the sub-space winch.
------------------------------------------------------------------------
svn log
also takes a --quiet
(-q
) switch, which suppresses the body of the
log message. When combined with --verbose
, it
gives just the names of the changed files.