Subversion (SVN) Commands Cheat Sheet - Version Control Guide

Comprehensive Subversion (SVN) commands cheat sheet for developers. Quickly find commands for reverting, committing with changelists, stashing changes, updating URLs, and understanding SVN result codes.

Subversion Cheatsheet

Subversion (SVN) Commands Cheat Sheet

This cheat sheet provides quick access to essential Subversion (SVN) commands for managing your code repositories efficiently. Whether you need to revert changes, manage commits, or understand SVN's status codes, this guide is for you.

Revert Changes to a Single File

Undoing modifications to a specific file is a common task. Use the svn merge command with a revision range to revert a file to its previous state.

$ svn merge -r HEAD:PREV <file>

Related: How do I return to an older version of our code in Subversion?

Commit with a Changelist

Organize your commits by grouping related files into changelists. This allows you to commit specific sets of changes together, even if they are spread across different directories.

$ svn changelist my-changelist mydir/dir1/file1.c mydir/dir2/myfile1.h
$ svn changelist my-changelist mydir/dir3/myfile3.c etc.
... (add all the files you want to commit together at your own rate)
$ svn commit -m"log msg" --changelist my-changelist

Review Changelist Status

Check the current status of your working copy, including files assigned to changelists, to ensure you are committing the correct set of changes.

$ svn status

--- Changelist 'math-fixes':
        button.c
M       integer.c
M       mathops.c

Source: SVN - How to commit multiple files in a single shot
Reference: svn changelist (cl)

Simulate Git Stash with SVN

If you're coming from Git, you might miss the stash command. You can simulate this functionality in SVN by creating a patch of your uncommitted changes and then reverting your working copy.

svn diff > patch_name.patch; svn revert -R .    # git stash
patch -p0 < patch_name.patch                    # git stash apply

Source: Temporarily put away uncommitted changes in Subversion (a la “git-stash”)
See also: Using patch as a subversion stash by Jay Fields

Update Repository URL

When your SVN repository location changes, you can update your working copy's URL without needing to check out the entire repository again using svn relocate.

$ svn relocate https://sub.someaddress.com.tr/project

Change SVN repository URL

Understanding SVN Result Codes

SVN uses single-character codes to indicate the status of files in your working copy. Understanding these codes is crucial for interpreting the output of commands like svn status.

$ svn help status
  The first seven columns in the output are each one character wide:
    ' ' no modifications
    'A' Added
    'C' Conflicted
    'D' Deleted
    'I' Ignored
    'M' Modified
    'R' Replaced
    'X' an unversioned directory created by an externals definition
    '?' item is not under version control
    '!' item is missing (removed by non-svn command) or incomplete
    '~' versioned item obstructed by some item of a different kind

The StackOverflow article also has an helpful one-liner to quickly find specific codes.

svn help status | grep \'\?\'
svn help status | grep \'\!\'
svn help status | grep \'\YOUR_SYMBOL_HERE\'

What do the result codes in SVN mean?