Viewing and managing changes

svn status
The svn status command provides an overview of changes made in the working copy since the last update or commit. svn status run at the top of the working copy detects all changes made in the tree. svn status run with a specified path gives information relevant to that address.

$ svn status database/flatfile

The specified path could be directory of file

$ svn status -v

With the -v option, svn status shows every file even if it wasn't changed

$ svn status -u

With the -u option, svn status shows outdated files.

Following is a sample output of svn status

A    45    23    user1    testscript.php
M    45    20    user2    index.html

Take a look at the left most column. Following is these letters mean:

A: scheduled for addition
C: conflict detected, resolve before committing
D: scheduled for deletion
M: file contents modified

The second column is the revision number, followed by revision where the file was changed, user name of the person who made the modification, and file name.

svn log
svn log shows log messages, date, author, revisions, and more.

$ svn log
$ svn log 9
$ svn log -r 4:5
$ svn log -r 5:3
$ svn log index.php
$ svn log -v -r 3

The first command gives a simple svn log
The second command shows log for revision 9
The third command shows logs for revisions 3, 4, and 5
The fourth command is the same as the third command with the exception the logs are printed in reverse order i.e. revisions 5, 4, and 3
The fifth command shows all logs for a specified file
The last command shows logs in verbose mode

svn diff
svn diff shows each and every change that was made.

$ svn diff 
$ svn diff -r 3 index.php
$ svn diff -r 3:4 index.php

The first command show all changes in the working copy.
The second command compares the file in the working copy to the file in the repository
The last command compares repository revisions

svn revert

svn revert filename

undos changes make to a file in the working copy.

Resolving Conflicts
If you two or more users have modified a file, between commits, there would be a conflict. To resolve a conflict, users can either postpone the conflict, merge conflicts by hand, override the file with your changes, or discard your changes. To postpone conflict resolution, type p when svn update notifies of a conflict. To merge conflicts manually, edit the file using any non-formatting text editor such as vi, emacs, gedit, notepad, etc. All the content between <<<<.mine and ====== are your modifications. All the content between ===== and >>>>>>.r2 is the other user's modification. Then type:

$ svn resolve --accept file

To discard your changes and accept the other user's changes:

$ svn resolve --accept theirs-full index.php

To override the file with your changes:

$ svn resolve --accept mine-full index.php