Catalog / Subversion (SVN) Cheatsheet

Subversion (SVN) Cheatsheet

A comprehensive guide to Subversion (SVN) commands and concepts for version control.

Basic Commands

Checkout

svn checkout URL [PATH]

Downloads a working copy from the repository.

Example:
svn checkout https://example.com/svn/repo myrepo

svn co URL [PATH]

Shorthand for svn checkout.

Update

svn update [PATH]

Brings your working copy up to date with the latest changes from the repository.

Example:
svn update (updates the current directory)

svn up [PATH]

Shorthand for svn update.

Commit

svn commit [PATH] -m "MESSAGE"

Sends your changes to the repository.

Example:
svn commit -m "Fixed a bug"

svn ci [PATH] -m "MESSAGE"

Shorthand for svn commit.

Add

svn add PATH

Adds a file or directory to version control.

Example:
svn add newfile.txt

Delete

svn delete PATH

Marks a file or directory for deletion in the next commit.

Example:
svn delete oldfile.txt

svn del PATH

Shorthand for svn delete.

svn remove PATH

Alias for svn delete.

Status

svn status [PATH]

Shows the status of files and directories in your working copy.

Example:
svn status

svn st [PATH]

Shorthand for svn status.

Branching and Merging

Branching

svn copy URL URL -m "MESSAGE"

Creates a branch in the repository.

Example:
svn copy https://example.com/svn/repo/trunk https://example.com/svn/repo/branches/mybranch -m "Creating a new branch"

svn copy WCURL URL -m "MESSAGE"

Copy from working copy to create a branch in the repository

svn copy . https://example.com/svn/repo/branches/newbranch -m "Creating branch from WC"

Switching

svn switch URL [PATH]

Switches your working copy to a different branch or tag.

Example:
svn switch https://example.com/svn/repo/branches/mybranch

svn sw URL [PATH]

Shorthand for svn switch.

Merging

svn merge URL [PATH]

Merges changes from a branch or tag into your working copy.

Example:
svn merge https://example.com/svn/repo/branches/mybranch

svn merge SOURCE_URL@REV1:REV2 DEST_PATH

Merge changes from a specific revision range. Example: svn merge https://example.com/svn/repo/branches/mybranch@100:200 .

Resolve Conflicts

After merging, conflicts may arise. Use svn resolve --accept working PATH to resolve them.

svn resolve --accept mine-full filename.txt to accept your version.
svn resolve --accept theirs-full filename.txt to accept the repository version.

Inspecting History

Log

svn log [PATH]

Shows the commit history of a file or directory.

Example:
svn log myfile.txt

svn log -v [PATH]

Shows the commit history with verbose output.

Diff

svn diff [PATH]

Shows the differences between your working copy and the repository.

Example:
svn diff myfile.txt

svn diff -r REV1:REV2 [PATH]

Shows the differences between two revisions.

Example:
svn diff -r 100:200 myfile.txt

Blame

svn blame PATH

Shows who last modified each line of a file.

Example:
svn blame myfile.txt

svn praise PATH

Alias for svn blame.

svn annotate PATH

Alias for svn blame.

Info

svn info [PATH]

Displays information about a file or directory, such as its URL and revision.

Example:
svn info myfile.txt

Advanced Operations

Revert

svn revert PATH

Discards local changes and reverts a file or directory to its original state.

Example:
svn revert myfile.txt

svn revert -R PATH

Recursively reverts all changes in a directory.

Cleanup

svn cleanup - Cleans up a working copy after an interrupted operation.

Locking

svn lock PATH -m "MESSAGE"

Locks a file in the repository to prevent others from modifying it.

Example:
svn lock myfile.txt -m "Locking for editing"

svn unlock PATH

Unlocks a file in the repository.

Example:
svn unlock myfile.txt

Import

svn import PATH URL -m "MESSAGE"

Imports an unversioned tree into the repository.

Example:
svn import mydirectory https://example.com/svn/repo/trunk -m "Importing initial project"

Export

svn export URL [PATH]

Exports a clean directory tree from the repository, without version control metadata.

Example:
svn export https://example.com/svn/repo/trunk myexport

svn export --revision REV URL [PATH]

Exports a specific revision

Example:
svn export --revision 123 https://example.com/svn/repo/trunk myexport