Subversion

  • Apache-style license

Editing files

  • After checking out files, commands can be run in any working directory with an .svn subdirectory

Checkout a file

svn <checkout,co> <svnroot-url>/<dir-name>/trunk <working-dir>

Identify which working files have changed

cd <working-dir>
svn status [<file>]
  • See which working files have changed since the last time they were checked out
  • Not affected by the timestamp (if a file has been touched but the contents are not changed, then the file has not changed) 

Show all changes to working files

cd <working-dir>
svn diff [<file>]
svn diff -r <revision1>:<revision2> [<file>]
  • See how a working file has changed since it was checked out (will diff all changed files by default)

Check-in a file

cd <working-dir>
svn commit [-m "comment"] [<file>]
  • Check-in working files that have changed (will check-in all such files by default)
  • Fails if a file is "out-of-date", in which case an update should be done first)

Update the working files

cd <working-dir>
svn update
  • Re-checkout the files
  • Automatically attempts to merge changes if needed

Abandon changes to working files

cd <working-dir>
svn revert [<file>]
  • Re-checkout the files, overwriting any working files that have been changed

Show the history log

cd <working-dir>
svn log [<file>]

Resolving conflicts


Cleaning up temporary files

svn resolved <file>
  • After a conflict has been resolved by hand

Modifying the repository

Create a directory

svn mkdir <dir>
  • Add a directory to the repository
  • Must be followed by a commit
  • Creates the working copy and schedules the dir for addition to the repository (does not commit it)
  • All parent directories must already exist

Add a file

svn add <file, dir> [--non-recursive,-N]
  • Add to the repository
  • Must be followed by a commit
  • Schedules the file or dir for addition to the repository (does not commit it)
  • By default, recursively adds the contents of a directory

Delete a file

svn delete <file, dir>
  • Delete from the repository
  • Must be followed by a commit
  • Deletes the working copy and schedules the file or dir for deletion from the repository (does not commit the deletion)

Copy a file

svn copy <src-file> <dest-file>
  • Add a copy of a file to the repository
  • Must be followed by a commit 
  • Copies the working file and schedules the new copy for addition to the repository (does not commit it)
  • Copies the history (when committed)

Move a file

svn move <src-file> <dest-file>
  • Move a file in the repository
  • Must be followed by a commit 
  • Moves the working file and schedules the file to be moved in the repository (does not commit the move)
  • Retains the history (when committed)

Administrative commands

Create a repository

svnadmin create <svnroot-path>

Import a project in Subversion

Directory structure:
<working-dir>/branches
<working-dir>/tags
<working-dir>/trunk/<files>
svn import <working-dir> <svnroot-url>/dir-name -m "<comment>"

Changes from CVS

  • Renamed / copied / moved / removed files are versioned
  • Directories and renames are versioned
  • Commits are atomic; a failed commit does not result in corrupted files
  • Branching and tagging are inexpensive operations
  • Costs are proportional to change size, not project size
  • Symbolic links are versioned in Unix
  • Efficient versioning of binary files
  • Files are organized as a set of directories, rather than a set of projects



Resources
Sources
  • http://subversion.tigris.org
  • http://svnbook.red-bean.com - Version Control with Subversion