Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

SVN Basics

This page includes explanations of terms and commands for Subversion or SVN.

Terminology

URL - a resource locator used for some SVN commands; in the case of Subversion these look like 'svn://repo/path/to/something'

...

revert - clobber your local changes in the working copy and replace with the current copy in the remote repository

Global config for ignoring files

Typically in most coding projects, there are local files which will be created by an IDE or other tool which should always be ignored by SVN.

...

These will apply to all subversion directories and files so make sure that the files you include here really would never be checked into version control.

Commands

All commands below assume that you are in a command shell like bash on Linux and that the current working directory is a local working copy of a structure node that has been checkout out of the repository.

...

Note that some (most) arguments to these commands like path/to/file are completely bogus and should be replaced by valid files in your working copy or the remote repository (depending on the command).

Checkout a structure node

svn co svn://repo/some/dir

Show information about the repository

This command will print out general repository information like your current revision # and the repository root.

...

Check the SVN docs for a full list of all these abbreviations.

Show node contents

svn ls some/relative/path/

...

svn ls svn://repo/some/path/

Synchronize your copy with the remote repository

svn up

Add files to the repository

This command can be used to add files:

...

The deletion will occur when you commit.

Deleting Files

To delete files use this command:

...

You also need to perform a commit to delete the files in the repository and not just the local copy.

Commit changes

This command is used to commit your local changes to the repository:

...

The list of files or directories to commit is optional, but it is usually a good idea to include it.

Copy file or directory from one place to another

svn cp src/dir/or/file target/dir/or/file

Create a directory in the repository

svn mkdir path/to/dir

Perform a merge

Warning
titleAdvanced Command

Merging is an advanced operation.  Always use '--dry-run' to check the results of the command before actually executing it.  And always merge equivalent structure nodes when merging a branch back into the trunk, or you will screw up the trunk.

...

svn cp m "making a branch" ^/projects/foo/trunk ^/projects/foo/branches/foo-dev

Make a tag

 

Warning
titleAdvanced Command

Making tags is an advanced operation.  Most general users do not need to make tags, and for Maven projects this is done automatically during the release procedures.  Never change a tag once it is made.  Should changes be required, the preferred method is making them in the trunk and then making a new tag.

...

svn cp -m "making a tag" ^/projects/foo/trunk ^/projects/foo/tags/foo-1.2.3

Reverting changes  

svn revert path/to/broken/local/file

Setting properties

Warning
titleAdvanced Command

This command should usually be done by the repository administrator.  To have Subversion ignore files in your local copy, see the section above entitle "Global config for ignoring files".

...

svn propset svn:ignore "*.log" .

Tips and Warnings

Do not EVER checkout an SVN project into another Subversion structure node.  This has the potential to create some serious issues when executing Subversion commands, and it will also confuse you.

...