skip to primary navigationskip to content
 

Examining Changes

Examining History and Changes

For more details on using Subversion visit the Subversion online instruction book.


As an author, it is likely that you will want to look at differences between two revisions of the same file, or two separate files.

Note: These commands can be used without any network access.
Useful if you are working remotely without a network connection.

Svn log

This shows you broad information about a file or directory.
You can use this command to find out who made changes to a file or directory, which revision it changed at, the time and date of the revision and the accompanying log message.
Using the -v verbose switch will provide further information still:

	$svn log -v
	.................................................
	r8 | sally | 2007-05-14 09:15:27 -0500 | 1 line		#this line will appear regardless of the use of the -v switch
	Changed paths:
	M /trunk/directoryA/fileA-b.html
	A /trunk/directoryA/newfile.html
	
	This is a new file, called newfile.html which was created as a test.     #this shows the text which changed in the file
	.................................................

Svn cat

Using svn cat and svn list, you can view various revisions of files and directories without changing the working revision of your working copy.
If you want to examine an earlier version of a file and not necessarily the differences between them you would run a command such as:

svn cat -r 247 blame-b.html
Where:
	-r 	= revision
	247 	=  is an earlier revision of this file examingchanges-b.html
The result would be an onscreen print out of the contents of this revision of the file, just like using Unix cat.

You can also redirect the output directly into a file:

	$svn cat -r 247 blame-b.html > blame-b.html.v2

Svn list

This displays the files in a directory for any given revision, without having to download them to your local machine:

	$svn list cl-preview/html/supporters-club
	.htaccess
	collab-b.html
	howtojoin-b.html
	index-b.html
	joining-proforma.txt
	jokemember.html
	members-b.html
	recruitment-fair-2005-b.html
	recruitment-fair-2006-b.html
	uconfig.txt

To view more details about these files, use the -v switch:

	$svn list -v /cl-preview/html/supporters-club
	191 	mgk25	38	May 23 	12:16 	.htaccess
	185	mgk25	6012	May 22	10:15	collab-b.html
	186	mgk25	3793	May 22	17:48	howtojoin-b.html
	...

Svn status

To get an overview of changes you have made, use the command svn status.
If you use this command at the root of your working copy with no switches, it will detect all file and tree changes you have made.

An example of the sort of information svn status can return is below:

	A	directoryA/newfile-b.html   	#file is scheduled for addition
	C	directoryA/fileA-b.html	  	#file has textual conflicts from an update (see note below for details)
	D	directoryA/rubbish.html	  	#file is scheduled for deletion
	M	changed.html		  	#the content of this file has local modifications
Conflict
Changes received from the server during an update overlap with local changes that you have in your working copy.
These must be resolved before the file can be committed to the repository.
If you add the path of a file, you will get information about that item alone:
	$ svn status directoryA/rubbish.html
	D	directoryA/rubbish.html
If you use the switch -v (verbose), you will see the status of every item in your working copy, even if it hasn't changed:
	$ svn status -v
	
	M	44	23	sally	directoryA/changed.html
	D	44	18	harry	directoryA/rubbish.html
	A	 0	 ?	    ?	directoryA/newfile-b.html
		44	23	harry	directoryA/unchangedfile-b.html
		

The columns displayed are as follows:
1st column - file status (modify, delete, add, etc). If the file is unchanged, this will be blank.
2nd column - file revision (0 indicates a new file that has never entered the repository)
3rd column - revision that the file last changed. If the file is new, it will be marked with "?"
4th column - who made the changes. If the file is new, it will be marked with "?"
5th column - directory and file name.

Note:
None of the above contact the repository. This is local and compares the data in the .svn directory with the working copy.
To view updates from within the repository (i.e not locally):
	$ svn status -u -v
	
	M	*	44	23	sally	directoryA/changed.html
	D		44	18	harry	directoryA/rubbish.html
	A		 0	 ?	    ?	directoryA/newfile-b.html
		*	44	23	harry	directoryA/unchangedfile-b.html	
The asterisks indicate that these files have changed in the repository.
If you were to run svn update, these files in your working copy would be updated with changes from the repository.
This means that you either need to update to get the changes to unchangedfile-b.html, or your changed.html file will be rejected from the repository for being out-of-date.
Note:
Visit the online instruction book for more information on svn status

Svn diff

This command shows exactly the modifications made in your file.
The svn diff command produces an output comparing your working files against copies stored within your .svn area.

The following is an example of changes made to a file on the Computer Lab website.
Output is displayed with:
"-" for removed lines
"+" for added lines:


$svn diff contact/directions/index-b.html
Index: contact/directions/index-b.html
===================================================================
--- contact/directions/index-b.html     (revision 172)			#this indicates that the removed lines were revision 172
+++ contact/directions/index-b.html     (working copy)			#this indicates that the new lines are in the file which
									 is part of your working copy
@@ -64,17 +64,17 @@

The William Gates Building is 2 km (1.3 miles) west of the city
-centre, along Madingley Road, towards the American Cemetary. 		#this line had a spelling error
+centre, along Madingley Road, towards the American Cemetery. 		#this line has replaced the original with the correct spelling
Note:
Visit the online instruction book for more information on svn diff

Svn revert

If you find you have edited a file in error and need to start again, you can use the command svn revert to revert the file to its pre-modified state by overwriting the copy stored in the .svn area.
Svn revert can also undo any scheduled operations:

The syntax for using revert is:
	$svn revert index.html
	Reverted 'index.html'
To undo a scheduled operation:
	$ svn status rubbish.html   	#What is the status of this file?
		rubbish.html		#This file exists but has not changed since the last update
	
	$svn delete rubbish.html	#Delete the file
	D	rubbish.html		#File deleted
	
	$svn revert rubbishb.html	#Yikes! I didn't mean to delete that file. Revert, revert!
	Reverted 'rubbish.html'		#Delete operation reverted
	
	$svn status rubbish.html	#Has the operation really been stopped?
		'rubbish.html		#This file is still there and remains unchanged since last update.
Note:
Visit the online instruction book for more information on svn revert