SVN Command Reference
From VCGR Wiki
Contents |
Subversion for Eclipse
There is a project/plugin for Eclipse that allows you to use Subversion called Subclipse. This plugin can be downloaded from http://subclipse.tigris.org. Once downloaded, unzip the installation package into your Eclipse installation directory.
Overall Comments
- Subversion works using URLs most of the time. While many URL formats are permissable to SVN, the only one that you should be using is the svn://repository.server.name[:port]/path.to.repository. For the time being, the correct URL to use is svn://camillus.cs.virginia.edu:9002/GenesisII
- Subversion uses paths to differentiate between tags/branches/main trunk of a repository. You always need to indicate which of these you want to deal with. The following examples show how to checkout (and implicitly therefor how to name) different parts of Genesis II using the format indicated above
- svn checkout svn://camillus.cs.virginia.edu:9002/GenesisII/trunk GenII
- This command will check out the main trunk of the Genesis II repository into a local directory called GenII
- svn checkout svn://camillus.cs.virginia.edu:9002/GenesisII/branches/MarksPrivateBranch GenII
- This command will check out the branch called "MarksPrivateBranch" into a local directory called GenII
- svn checkout svn://camillus.cs.virginia.edu:9002/GenesisII/tags/GenII-v1.2 GenII
- This command will check out the tagged version of the system called GenII-v1.2 into a local directory called GenII
- svn checkout svn://camillus.cs.virginia.edu:9002/GenesisII/trunk GenII
- Most of the commands CAN deal with revision indicators. These can either be revision numbers, revision names, or timestamps
Some useful global switches
These are switches that are the same regardless of which subcommand is being used.
- --dry-run
- Runs the command without actually updating the local copy or the repository.
- --editor-cmd CMD
- Uses the specified editor command when editing log messages or property values
- --message (-m) MESSAGE
- Provides the log message on the command line
- --non-interactive
- Prevents Subversion from prompting for authentication information in the case of a failure. This is useful for scripting.
- --non-recursive
- Prevents Subversion from recursively applying a command to a directory tree.
- --recursive
- Forces Subversion to apply a command to a subtree. This is the default behavior.
- --revision (-r) REV
- Indicates a revision number/name/timestamp to work with. See section on revision numbers below for more details.
- --password PASS
- Passes in an authentication password on the command line
- --username NAME
- Passes in a user name on the command line.
Command Reference
- svn add PATH...
- Adds files, directories, or symbolic links to the repository upon a commit. You can undo this by using svn revert.
- svn blame TARGET[@REV]
- Shows author and revision information in-line for the specified files or URLs.
- svn praise/annotate/ann TARGET[@REV]
- These three commands are all pseudonyms for the blame command above.
- svn cat TARGET[@REV]
- Cat's the contents of a file or URL
- svn checkout URL[@REV]... [PATH]
- Checks out the repository at the given URL (into the given path).
- svn commit [PATH...]
- Commits changes into the branch/trunk from which you checked it out.
- svn copy SRC DST
- Copies the source to the path. This copy is not a simple file copy but is a repository copy (a special CHEAP copy that preserves history. This is the main way of creating branches and tags. For example, to create the MarksPrivateBranch branch indicated above, you would issue the command svn copy svn://mamba.cs.virginia.edu:9002/GenesisII/trunk svn://mamba.cs.virginia.edu:9002/GenesisII/branches/MarksPrivateCopy
- svn delete TARGET
- Deletes a specified target from the repository. If TARGET is a path, then you will need to commit -- if it's a URL, then the commit happens automatically.
- svn diff [-r N[:M]] {TARGET[@REV]...]
- Does a diff. This command is pretty expressive so please see the manual.
- svn help [SUBCOMMAND...]
- Get help on a subcommand.
- svn info [TARGET...]
- Get information about a local or remote item.
- svn list [TARGET[@REV]...]
- List the contents of a directory in the local space or the repository.
- svn lock TARGET...
- Lock a target.
- svn merge ...
- Used to merge branches/tags/etc. See full command help for details.
- svn mkdir TARGET...
- Creates a new directory under revision control. If TARGET is a local path, then you will need to commit -- if it's a URL, then the changes happens to the repository immediately.
- svn move SRC DST
- Moves a source to a destination. This can either be working directory to working directory (needing a commit), or URL to URL which happens immediately. This is the preferred way to rename an item in Subversion and is essentially a copy and a delete.
- svn resolved PATH...
- Indicates that a file or directory which had been in a conflicted state is now resolved. The user MUST issue this command in order to commit once a conflict is encountered.
- svn revert PATH...
- Undo all local edits.
- svn status [PATH...]
- Print the status of a working set of files and directories.
- svn switch URL [PATH]
- Modifies the local disk copy of a set of software to the URL indicated. For example, suppose that I was working in branch svn://mamba.cs.virginia.edu:9002/GenesisII/branches/MarksPrivateBranch and I decided to abandon that branch and work on the main trunk. Rather than create a new local copy of the main trunk, I could revert my copy to the main trunk by issuing the command svn switch svn://mamba.cs.virginia.edu:9002/GenesisII/trunk.
- svn unlock TARGET...
- Unlocks a previously locked file or directory.
- svn update [PATH...]
- Updates your local copy to the latest from your branch/trunk/tag.
Revision Specifiers
Most commands allow you to specify revision specifiers for them (for example, to check out revision 123 of the main trunk, or to get the version of the main trunk from a certain date). Three formats are allowed.
- Revision Number
- In this case you simply give the number of th revision that you want to use.
- Revision Keywords
- There are a few keywords that can be used that include HEAD, BASE, COMMITTED, and PREV.
- Revision Date
- You can give the date at which you would like a revision. The format for this is {date-pattern} (including the curly braces).
Checking What Changes Await
CVS users are used to issuing the cvs -n update ... command to find out what would happen if they were going to do an update. With Subversion, you don't need to do this. You can instead use svn status to get the same information.
