paulgorman.org

SVN (Subversion) cheatsheet

Basic commands

Create a new repository: svnadmin create /var/svn/newrepository

Add initial files to an empty repository: svn import myfile http://svn.example.com -m "Initial import."

List files: svn list http://svn.example.com/project/somedir

Checkout files to work on them: svn checkout http://svn.example.com/project/trunk

Update your local files to relect any changes in the repository: svn update

See what will change if you commit svn status

Commit your changes to the repository: svn commit -m "These are my changes.

Typical workflow

  1. Update your working copysvn update
  2. Make changes svn add/delete/copy/move
  3. Examine your changes svn status/diff
  4. Undo changes if needed svn revert
  5. Resolve conflicts svn update/resolve
  6. Finally, commit your changes svn commit

Trunk, branches, tags

$ svn list http://svn.example.com/project /trunk /branches /tags

The main line of development is contained in "trunk".

If a project has distinct development branches that share a lot of common code, the branches are stored in "branches". For example, if several departments in a company use the same application, but one of those departments needs a couple of things calculated with a slightly different algorythm, the varient code bases would be stored as different branches. Bugfixes that effect all branches can then be easily applied to all.

$ svn copy http://svn.example.com/project/trunk \ http://svn.example.com/project/branches/myproject \ -m "Creating a private branch of /project/trunk."

Changes from "trunk" can be applied to the branch with the merge function.

Tags are snapshots of trunk at a particular stage of development.

$ svn copy http://svn.example.com/project/trunk \ http://svn.example.com/project/tags/release-1.0 \ -m "Tagging release 1.0 of the project."

Links