Buy @ Amazon

SVN FAQ(s)

An avid reader I am, I encourage you to read at least a book on every technology you put to use to in your project(s). Also, it is indeed a good practice to keep reading QnA forums like in http://stackoverflow.com/questions/.

My favourite book for SVN (subversion) is Pragmatic Guide to Subversion.
Pragmatic Guide to Subversion

So here we go with our list of FAQs in SVN. Should you like to add solutions to the problems you have had faced in this page, I encourage you to please use the comments section of this page. I shall sooner or later add it to the list of "Question and Answers" that we have for SVN, below.
  1. How to get the list of files that become a part of a particular commit in SVN repository?<br/> For every commit to svn, the repo generates a REVISION number. Using this revision number, we can fire the following command to get the list of files
    svn log -qvr <revision>
    (Also, read stackoverflow.com for more details)
  2. How to find the difference in file content between two revisions? <br/> Syntax:  svn diff -r <PREV_REVISION>:<NEW_REVISION> <FILE_NAME>
    Example: svn diff -r 3277:3278 app/models/account.rb
  3. How to get the list of files changed between two revisions? <br/> Syntax:  svn diff -r <PREV_REVISION>:<NEW_REVISION> --summarize
    Example: svn diff -r 3277:HEAD --summarize will list the files modified\added\deleted files since revision 3277 till current revision in the repo
  4. How to see the changes between two revisions, not mere list of file changes but the actual content difference between the revisions?
    Syntax:  svn diff -r <PREV_REVISION>:<NEW_REVISION>
    Example: svn diff -r 3277:3276
  5. How to see the last 'N' commit logs? 
    Syntax:  svn log -l <limit>
          (or)  svn log --limit <limit> 
    Example: svn log -l 10 will display the last 10 commits' log messages
  6. How to see the last 'N' commit logs along with the list of [added\deleted\modified] files that were committed? 
    Syntax:  svn log -vl <limit>
          (or)  svn log --verbose --limit <limit> 
    Example: svn log -vl 10 will display the last 10 commits' log messages along with the list of modified files that were committed with each such commit.
  7. How to undo a commit in svn, when a commit's revision number is known? 
    Syntax:  svn merge -r <UNDO_REVISION>:<UNDO_REVISION-1> <URL of trunk\branch where commit needs to be undone>
    Example: svn merge -r 3278:3277 http://mysvnA1.thoughtworks.com/seesaw/branch/release_3.04/seesaw will undo the 3278 commit changes in your local code base which requires to be committed with perhaps the commit message like 'Commit to undo revision 3278 changes' 
  8. How to merge a branch to a trunk (or vice-versa)? 
    Syntax:  svn merge -r <REVISION_From#>:<REVISION_To#> <URL of the source branch (or trunk) from where the changes are taken>
    Example: svn merge -r 250:HEAD http://mysvnA1.thoughtworks.com/seesaw/branch/release_3.04/seesaw will pick the changes from r250 to the last of the revision and merge all those changes to your local copy of trunk, assuming that you ran the above command from your local working directory that points to remote trunk. You may now review the local changes as a result of merge. If you are not satisfied with the changes you can revert it. If you are however happy with the changes you may commit them to the remote trunk. 
  9. [More to come...]




Additional Reading Links:

  • Read Chapter 9 - Subversion Complete Reference, at svnbook



FYI: There exists better alternatives to SVN as central repository. Some of them being Git, Mercurial etc.

Some cool books on Git, that I'm aware of are:
Pro Git     Version Control with Git: Powerful Tools and Techniques for Collaborative Software Development     Pragmatic Version Control Using Git (Pragmatic Starter Kit)     in that order. If in your experience there are better books that helped you understand Git better, please do share your experience in the comments section.

Mercurial is just another alternative to svn (or actually to Git). The one book that I'm aware of for this tool is Mercurial: The Definitive Guide (Animal Guide).