simple guide to the SVN client
last updated 2011-07
this is just a simple reference. this is by no means meant to be an exhaustive reference
basics
SVN/Subversion is a free/open source version control system. it manages files and directories, and the changes made to them over time. it's able to recover previous versions as well as manage changes done to the files "concurrently" by several users
for each command you can get help by typing svn help command
further on, files in the commands refers to both files and directories
the development cycle
the development cycle consists of getting a copy of the version-controlled "project" (done once), updating the copy to the newest state, and committing the local changes
-
svn co url [path]
get a copy of the project/repository stored at given url (and store it at path)
this step is typically necessary to do only once
-
svn up [-r rev] [files]
update this copy to the latest revision (to the revision rev)
this command fetches all changes from the server and updates the local copy of the repository; if the local copy has some local modifications, those are preserved
if your local changes conflict with changes committed to the repository, you'll get a conflict on update. see the svn book for more details on resolving the conflicts
-
svn st [-u] [-q]
view the status of the local copy as compared to the version from the last update (or, as compared to the current version in the repository with
-u). the-qswitch stops the SVN client from reporting unversioned filesthe
svn stcommand lets you easily see what all has been changed. on top of that, thesvn st -ucommand lets you see what all files will be updated if thesvn upcommand is run -
svn diff [-r [rev1:]rev2]
the
svn diffcommand will show differences between the local copy and the last updated copy - "local edits". the form of this depends on thediff-cmdsetting of SVN; default is thediffprogram. this can be changed in the~/.subversion/configfileyou may also view differences between the local copy and the current repository state using
svn diff -r headanother useful option (e.g. when inspecting someone else's changes) is
svn diff -r rev1:rev2, that shows differences between the 2 revisions, rev1 and rev2 -
svn ci [files]
the final step is getting your local changes to the repository. the
svn cicommand commits all local changes (in given files) to the SVN repositorynote: make sure the files you're about to commit are up to date (using
svn up [files]) - SVN will not allow you to commit your changes if your copy is not updated to the latest revision
managing the files and directories
-
svn add files
add given files (and/or directories) under version control
-
svn mv from to
move within the versioned copy. typically implemented as
svn rmandsvn add, i.e. the change history is not preserved on the file in its new position -
svn rm files
remove given files from version control. beware, this typically also removes the files/folders from disk!
branching and more advanced use
for concepts and usage of branching see the SVN book
-
svn cp url1 url2
creates a copy of url1 as url2 in the repository
-
svn merge -r rev1:rev2 srcurl [dir]
apply changes from revision span rev1:rev2 (to dir) from the srcurl repository
-
svn switch url
switch this working copy to a different branch
-
svn log -v --stop-on-copy [url]
show log for the working copy, only up to the "copy" point - where the branch was created
-
svn merge -r rev1:head branchurl
run on a trunk working copy - merges all changes from the branch branchurl, where rev1 is the start of the branch - the revision where the copy command occurred
-
svn rm url
remove from repository via immediate commit; e.g. for closing a branch at url