Simple Guide to SVN Client
This is just a simple reference. This is by no means meant to be an exhaustive reference.
The 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 consist 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 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 last update (or, as compared to the current version in repository with -u). The -q switch stops the SVN client from reporting unversioned files.
The svn st command allows user to easily see what all has been changed. Above this, the svn st -u command allows user to see what all files will be updated if svn up command is run.
- svn diff [-r [rev1:]rev2]
The svn diff command will show differences between the local copy and the last updated copy - "local edits". The form of this depends on the diff-cmd setting of the SVN; default is diff program. This can be changed in the ~/.subversion/config file.
User may also view differences between local copy and the current repository state using svn diff -r head.
Another 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 ci command commits all local changes (in given files) to the SVN repository.
Note: 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 rm and svn add, i.e. the change history is not preserved on the file in new position.
- svn rm files
Remove given files from the 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 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 branch was created.
- svn merge -r rev1:head branchurl
Run on trunk working copy - merges all changes from the branch branchurl, where rev1 is the start of the branch - the revision where copy command occurred.
- svn rm url
Remove from repository via immediate commit; e.g. for closing of a branch at url.